home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Utilities / Font Management Utility / ChineseS / Xerox Font Management Utility.msi / Data1.cab / fmu.chm3 / skinsupport / madcaputilities.js < prev   
Text File  |  2011-04-21  |  88KB  |  4,021 lines

  1. // {{MadCap}} //////////////////////////////////////////////////////////////////
  2. // Copyright: MadCap Software, Inc - www.madcapsoftware.com ////////////////////
  3. ////////////////////////////////////////////////////////////////////////////////
  4. // <version>6.1.0.0</version>
  5. ////////////////////////////////////////////////////////////////////////////////
  6.  
  7. var gRuntimeFileType = FMCGetAttribute( document.documentElement, "MadCap:RuntimeFileType" );
  8.  
  9. var gLoaded                        = false;
  10. var gReadyFuncs                    = new Array();
  11. var gOnloadFuncs                = new Array();
  12. var gOnunloadFuncs                = new Array();
  13. var gPreviousOnloadFunction        = window.onload;
  14. var gPreviousOnunloadFunction    = window.onunload;
  15. var gReady                        = false;
  16.  
  17. if ( gPreviousOnunloadFunction != null )
  18. {
  19.     gOnunloadFuncs.push( gPreviousOnunloadFunction );
  20. }
  21.  
  22. window.onload = function()
  23. {
  24.     for ( var i = 0, length = gReadyFuncs.length; i < length; i++ )
  25.     {
  26.         gReadyFuncs[i]();
  27.     }
  28.  
  29.     if (gPreviousOnloadFunction != null)
  30.     {
  31.         gPreviousOnloadFunction();
  32.     }
  33.     
  34.     gReady = true;
  35.     
  36.     MCGlobals.Init();
  37.     
  38.     FMCRegisterCallback( "MCGlobals", MCEventType.OnInit, OnMCGlobalsInit, null );
  39. };
  40.  
  41. window.onunload = function()
  42. {
  43.     for ( var i = 0, length = gOnunloadFuncs.length; i < length; i++ )
  44.     {
  45.         gOnunloadFuncs[i]();
  46.     }
  47. };
  48.  
  49. function OnMCGlobalsInit( args )
  50. {
  51.     for ( var i = 0, length = gOnloadFuncs.length; i < length; i++ )
  52.     {
  53.         gOnloadFuncs[i]();
  54.     }
  55.     
  56.     gLoaded = true;
  57. }
  58.  
  59. //
  60. //    Helper functions
  61. //
  62.  
  63. function FMCIsWebHelp()
  64. {
  65.     var targetType = FMCGetAttribute( document.documentElement, "MadCap:TargetType" );
  66.     
  67.     return targetType.Contains( "WebHelp" );
  68. }
  69.  
  70. function FMCIsWebHelpAIR()
  71. {
  72.     return document.location.href.StartsWith( "app:/" );
  73. }
  74.  
  75. function FMCIsHtmlHelp()
  76. {
  77.     var targetType = FMCGetAttribute(document.documentElement, "MadCap:TargetType");
  78.  
  79.     return targetType == "HtmlHelp";
  80. }
  81.  
  82. function FMCIsDotNetHelp()
  83. {
  84.     var targetType = FMCGetAttribute( document.documentElement, "MadCap:TargetType" );
  85.     
  86.     return targetType == "DotNetHelp";
  87. }
  88.  
  89. function FMCIsTopicPopup( win )
  90. {
  91.     return win.parent != win && win.parent.name == "body";
  92. }
  93.  
  94. var gLiveHelpEnabled    = null;
  95.  
  96. function FMCIsLiveHelpEnabled()
  97. {
  98.     if ( gLiveHelpEnabled == null )
  99.     {
  100.         var xmlDoc        = CMCXmlParser.GetXmlDoc( MCGlobals.RootFolder + MCGlobals.SubsystemFile, false, null, null );
  101.         
  102.         if ( xmlDoc == null )
  103.         {
  104.             gLiveHelpEnabled = false;
  105.         }
  106.         else
  107.         {
  108.             var projectID    = xmlDoc.documentElement.getAttribute( "LiveHelpOutputId" );
  109.             
  110.             gLiveHelpEnabled = projectID != null;
  111.         }
  112.     }
  113.     
  114.     return gLiveHelpEnabled;
  115. }
  116.  
  117. function FMCInPreviewMode()
  118. {
  119.     return MCGlobals.InPreviewMode;
  120. }
  121.  
  122. var gSkinPreviewMode    = null;
  123.  
  124. function FMCIsSkinPreviewMode()
  125. {
  126.     if ( gSkinPreviewMode == null )
  127.     {
  128.         var xmlDoc        = CMCXmlParser.GetXmlDoc( MCGlobals.RootFolder + MCGlobals.SubsystemFile, false, null, null );
  129.         
  130.         if ( xmlDoc == null )
  131.         {
  132.             gSkinPreviewMode = false;
  133.         }
  134.         else
  135.         {
  136.             gSkinPreviewMode = FMCGetAttributeBool( xmlDoc.documentElement, "SkinPreviewMode", false );
  137.         }
  138.     }
  139.     
  140.     return gSkinPreviewMode;
  141. }
  142.  
  143. function FMCGetSkin()
  144. {
  145.     var xmlDoc = null;
  146.     var path = null;
  147.  
  148.     if ( MCGlobals.InPreviewMode )
  149.     {
  150.         path = "Skin/";
  151.     }
  152.     else
  153.     {
  154.         path = FMCGetSkinFolderAbsolute();
  155.     }
  156.  
  157.     xmlDoc = CMCXmlParser.GetXmlDoc( path + "Skin.xml", false, null, null );
  158.  
  159.     return xmlDoc;
  160. }
  161.  
  162. function FMCGetStylesheet()
  163. {
  164.     var stylesheetDoc = null;
  165.  
  166.     if ( MCGlobals.InPreviewMode )
  167.     {
  168.         path = "Skin/";
  169.     }
  170.     else
  171.     {
  172.         path = FMCGetSkinFolderAbsolute();
  173.     }
  174.  
  175.     stylesheetDoc = CMCXmlParser.GetXmlDoc( path + "Stylesheet.xml", false, null, null );
  176.  
  177.     return stylesheetDoc;
  178. }
  179.  
  180. function FMCIsIE55()
  181. {
  182.     return navigator.appVersion.indexOf( "MSIE 5.5" ) != -1;
  183. }
  184.  
  185. function FMCIsSafari()
  186. {
  187.     return typeof( document.clientHeight ) != "undefined";
  188. }
  189.  
  190. function FMCGetSkinFolder()
  191. {
  192.     var skinFolder    = null;
  193.     
  194.     if ( MCGlobals.RootFrame != null )
  195.     {
  196.         skinFolder = MCGlobals.RootFrame.gSkinFolder;
  197.     }
  198.     else
  199.     {
  200.         skinFolder = MCGlobals.SkinFolder;
  201.     }
  202.     
  203.     return skinFolder;
  204. }
  205.  
  206. function FMCGetSkinFolderAbsolute()
  207. {
  208.     var skinFolder    = null;
  209.     
  210.     if ( MCGlobals.RootFrame != null )
  211.     {
  212.         skinFolder = MCGlobals.RootFrame.MCGlobals.RootFolder + MCGlobals.RootFrame.gSkinFolder;
  213.     }
  214.     else
  215.     {
  216.         skinFolder = MCGlobals.RootFolder + MCGlobals.SkinFolder;
  217.     }
  218.     
  219.     return skinFolder;
  220. }
  221.  
  222. function FMCGetBodyHref()
  223. {
  224.     var bodyLocation = MCGlobals.BodyFrame.document.location;
  225.     var bodyHref = bodyLocation.protocol + (!FMCIsHtmlHelp() ? "//" : "") + bodyLocation.host + bodyLocation.pathname + bodyLocation.hash;
  226.  
  227.     bodyHref = FMCEscapeHref( bodyHref );
  228.     
  229.     var bodyHrefUrl = new CMCUrl( bodyHref );
  230.  
  231.     return bodyHrefUrl;
  232. }
  233.  
  234. function FMCGetHref( currLocation )
  235. {
  236.     var href    = currLocation.protocol + (!FMCIsHtmlHelp() ? "//" : "") + currLocation.host + currLocation.pathname;
  237.  
  238.     href = FMCEscapeHref( href );
  239.  
  240.     return href;
  241. }
  242.  
  243. function FMCEscapeHref( href )
  244. {
  245.     var newHref    = href.replace( /\\/g, "/" );
  246.     newHref = newHref.replace( /%20/g, " " );
  247.     newHref = newHref.replace( /;/g, "%3B" );    // For Safari
  248.  
  249.     return newHref;
  250. }
  251.  
  252. function FMCGetRootFolder( currLocation )
  253. {
  254.     var href        = FMCGetHref( currLocation );
  255.     var rootFolder    = href.substring( 0, href.lastIndexOf( "/" ) + 1 );
  256.  
  257.     return rootFolder;
  258. }
  259.  
  260. function FMCGetPathnameFolder( currLocation )
  261. {
  262.     var pathname    = currLocation.pathname;
  263.  
  264.     // This is for when viewing over a network. IE needs the path to be like this.
  265.  
  266.     if ( currLocation.protocol.StartsWith( "file" ) )
  267.     {
  268.         if ( !String.IsNullOrEmpty( currLocation.host ) )
  269.         {
  270.             pathname = "/" + currLocation.host + currLocation.pathname;
  271.         }
  272.     }
  273.  
  274.     //
  275.  
  276.     pathname = pathname.replace( /\\/g, "/" );
  277.     //pathname = pathname.replace( /%20/g, " " );
  278.     pathname = pathname.replace( /;/g, "%3B" );    // For Safari
  279.     pathname = pathname.substring( 0, pathname.lastIndexOf( "/" ) + 1 );
  280.  
  281.     return pathname;
  282. }
  283.  
  284. function FMCGetRootFrame()
  285. {
  286.     var currWindow    = window;
  287.     
  288.     while ( currWindow )
  289.     {
  290.         if ( currWindow.name.Contains( "MCWebHelp" ) )
  291.         {
  292.             break;
  293.         }
  294.         else if ( currWindow == top )
  295.         {
  296.             currWindow = null;
  297.             
  298.             break;
  299.         }
  300.         
  301.         currWindow = currWindow.parent;
  302.     }
  303.     
  304.     return currWindow;
  305. }
  306.  
  307. var gImages    = new Array();
  308.  
  309. function FMCPreloadImage( imgPath )
  310. {
  311.     if ( !FMCIsWebHelp() || (!FMCInPreviewMode() && !FMCGetHelpSystem().PreloadImages) )
  312.     {
  313.         return;
  314.     }
  315.     
  316.     if ( imgPath == null )
  317.     {
  318.         return;
  319.     }
  320.     
  321.     if ( imgPath.StartsWith( "url", false ) && imgPath.EndsWith( ")", false ) )
  322.     {
  323.         imgPath = FMCStripCssUrl( imgPath );
  324.     }
  325.     
  326.     var index    = gImages.length;
  327.     
  328.     gImages[index] = new Image();
  329.     gImages[index].src = imgPath;
  330. }
  331.  
  332. function FMCTrim( str )
  333. {
  334.     return FMCLTrim( FMCRTrim( str ) );
  335. }
  336.  
  337. function FMCLTrim( str )
  338. {
  339.     for ( var i = 0; i < str.length && str.charAt( i ) == " "; i++ );
  340.     
  341.     return str.substring( i, str.length );
  342. }
  343.  
  344. function FMCRTrim( str )
  345. {
  346.     for ( var i = str.length - 1; i >= 0 && str.charAt( i ) == " "; i-- );
  347.     
  348.     return str.substring( 0, i + 1 );
  349. }
  350.  
  351. function FMCContainsClassRoot( className )
  352. {
  353.     var ret = null;
  354.     
  355.     for ( var i = 1; i < arguments.length; i++ )
  356.     {
  357.         var classRoot = arguments[i];
  358.         
  359.         if ( className && (className == classRoot || className.indexOf( classRoot + "_" ) == 0) )
  360.         {
  361.             ret = classRoot;
  362.             
  363.             break;
  364.         }
  365.     }
  366.     
  367.     return ret;
  368. }
  369.  
  370. function FMCGetChildNodeByTagName( node, tagName, index )
  371. {
  372.     var foundNode   = null;
  373.     var numFound    = -1;
  374.     
  375.     for ( var currNode = node.firstChild; currNode != null; currNode = currNode.nextSibling )
  376.     {
  377.         if ( currNode.nodeName == tagName )
  378.         {
  379.             numFound++;
  380.             
  381.             if ( numFound == index )
  382.             {
  383.                 foundNode = currNode;
  384.                 
  385.                 break;
  386.             }
  387.         }
  388.     }
  389.     
  390.     return foundNode;
  391. }
  392.  
  393. function FMCGetLastChildNodeByTagName( node, tagName )
  394. {
  395.     var foundNode = null;
  396.  
  397.     for ( var currNode = node.lastChild; currNode != null; currNode = currNode.previousSibling )
  398.     {
  399.         if ( currNode.nodeName == tagName )
  400.         {  
  401.             foundNode = currNode;
  402.  
  403.             break;
  404.         }
  405.     }
  406.  
  407.     return foundNode;
  408. }
  409.  
  410. function FMCGetChildNodesByTagName( node, tagName )
  411. {
  412.     var nodes   = new Array();
  413.     
  414.     for ( var i = 0; i < node.childNodes.length; i++ )
  415.     {
  416.         if ( node.childNodes[i].nodeName == tagName )
  417.         {
  418.             nodes[nodes.length] = node.childNodes[i];
  419.         }
  420.     }
  421.     
  422.     return nodes;
  423. }
  424.  
  425. function FMCGetChildNodeByAttribute( node, attributeName, attributeValue )
  426. {
  427.     var foundNode   = null;
  428.  
  429.     for ( var currNode = node.firstChild; currNode != null; currNode = currNode.nextSibling )
  430.     {
  431.         if ( currNode.getAttribute( attributeName ) == attributeValue )
  432.         {
  433.             foundNode = currNode;
  434.  
  435.             break;
  436.         }
  437.     }
  438.  
  439.     return foundNode;
  440. }
  441.  
  442. function FMCGetChildIndex( node )
  443. {
  444.     var index = -1;
  445.  
  446.     for ( var currNode = node; currNode != null; currNode = currNode.previousSibling )
  447.     {
  448.         if ( currNode.nodeType == 1 )
  449.         {
  450.             index++;
  451.         }
  452.     }
  453.  
  454.     return index;
  455. }
  456.  
  457. function FMCGetSiblingNodeByTagName( node, tagName )
  458. {
  459.     var foundNode = null;
  460.  
  461.     for ( var currNode = node.nextSibling; currNode != null; currNode = currNode.nextSibling )
  462.     {
  463.         if ( currNode.nodeName == tagName )
  464.         {  
  465.             foundNode = currNode;
  466.  
  467.             break;
  468.         }
  469.     }
  470.  
  471.     return foundNode;
  472. }
  473.  
  474. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  475.  
  476. function FMCStringToBool( stringValue )
  477. {
  478.     var boolValue        = false;
  479.     var stringValLower    = stringValue.toLowerCase();
  480.  
  481.     boolValue = stringValLower == "true" || stringValLower == "1" || stringValLower == "yes";
  482.  
  483.     return boolValue;
  484. }
  485.  
  486. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  487.  
  488. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  489.  
  490. function FMCGetAttributeBool( node, attributeName, defaultValue )
  491. {
  492.     var boolValue    = defaultValue;
  493.     var value        = FMCGetAttribute( node, attributeName );
  494.     
  495.     if ( value )
  496.     {
  497.         boolValue = FMCStringToBool( value );
  498.     }
  499.     
  500.     return boolValue;
  501. }
  502.  
  503. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  504.  
  505. function FMCGetAttributeInt( node, attributeName, defaultValue )
  506. {
  507.     var intValue    = defaultValue;
  508.     var value        = FMCGetAttribute( node, attributeName );
  509.     
  510.     if ( value != null )
  511.     {
  512.         intValue = parseInt( value );
  513.     }
  514.     
  515.     return intValue;
  516. }
  517.  
  518. function FMCGetAttributeStringList( node, attributeName, delimiter )
  519. {
  520.     var list    = null;
  521.     var value    = FMCGetAttribute( node, attributeName );
  522.     
  523.     if ( value != null )
  524.     {
  525.         list = value.split( delimiter );
  526.     }
  527.     
  528.     return list;
  529. }
  530.  
  531. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  532.  
  533. function FMCGetAttribute( node, attribute )
  534. {
  535.     var value   = null;
  536.     
  537.     if ( node.getAttribute( attribute ) != null )
  538.     {
  539.         value = node.getAttribute( attribute );
  540.     }
  541.     else if ( node.getAttribute( attribute.toLowerCase() ) != null )
  542.     {
  543.         value = node.getAttribute( attribute.toLowerCase() );
  544.     }
  545.     else
  546.     {
  547.         var namespaceIndex    = attribute.indexOf( ":" );
  548.         
  549.         if ( namespaceIndex != -1 )
  550.         {
  551.             value = node.getAttribute( attribute.substring( namespaceIndex + 1, attribute.length ) );
  552.         }
  553.     }
  554.     
  555.     if ( typeof( value ) == "string" && value == "" )
  556.     {
  557.         value = null;
  558.     }
  559.     
  560.     return value;
  561. }
  562.  
  563. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  564.  
  565. function FMCGetMCAttribute( node, attribute )
  566. {
  567.     var value    = null;
  568.     
  569.     if ( node.getAttribute( attribute ) != null )
  570.     {
  571.         value = node.getAttribute( attribute );
  572.     }
  573.     else if ( node.getAttribute( attribute.substring( "MadCap:".length, attribute.length ) ) )
  574.     {
  575.         value = node.getAttribute( attribute.substring( "MadCap:".length, attribute.length ) );
  576.     }
  577.     
  578.     return value;
  579. }
  580.  
  581. function FMCRemoveMCAttribute( node, attribute )
  582. {
  583.     var value    = null;
  584.     
  585.     if ( node.getAttribute( attribute ) != null )
  586.     {
  587.         value = node.removeAttribute( attribute );
  588.     }
  589.     else if ( node.getAttribute( attribute.substring( "MadCap:".length, attribute.length ) ) )
  590.     {
  591.         value = node.removeAttribute( attribute.substring( "MadCap:".length, attribute.length ) );
  592.     }
  593.     
  594.     return value;
  595. }
  596.  
  597. function FMCGetClientWidth( winNode, includeScrollbars )
  598. {
  599.     var clientWidth = null;
  600.     
  601.     if ( typeof( winNode.innerWidth ) != "undefined" )
  602.     {
  603.         clientWidth = winNode.innerWidth;
  604.         
  605.         if ( !includeScrollbars && FMCGetScrollHeight( winNode ) > winNode.innerHeight )
  606.         {
  607.             clientWidth -= 19;
  608.         }
  609.     }
  610.     else if ( FMCIsQuirksMode( winNode ) )
  611.     {
  612.         clientWidth = winNode.document.body.clientWidth;
  613.     }
  614.     else if ( winNode.document.documentElement )
  615.     {
  616.         clientWidth = winNode.document.documentElement.clientWidth;
  617.     }
  618.     
  619.     return clientWidth;
  620. }
  621.  
  622. function FMCGetClientHeight( winNode, includeScrollbars )
  623. {
  624.     var clientHeight    = null;
  625.     
  626.     if ( typeof( winNode.innerHeight ) != "undefined" )
  627.     {
  628.         clientHeight = winNode.innerHeight;
  629.         
  630.         if ( !includeScrollbars && FMCGetScrollWidth( winNode ) > winNode.innerWidth )
  631.         {
  632.             clientHeight -= 19;
  633.         }
  634.     }
  635.     else if ( FMCIsQuirksMode( winNode ) )
  636.     {
  637.         clientHeight = winNode.document.body.clientHeight;
  638.     }
  639.     else if ( winNode.document.documentElement )
  640.     {
  641.         clientHeight = winNode.document.documentElement.clientHeight;
  642.     }
  643.     
  644.     return clientHeight;
  645. }
  646.  
  647. function FMCGetClientCenter( winNode )
  648. {
  649.     var centerX    = FMCGetScrollLeft( winNode ) + (FMCGetClientWidth( winNode, false ) / 2);
  650.     var centerY    = FMCGetScrollTop( winNode ) + (FMCGetClientHeight( winNode, false ) / 2);
  651.     
  652.     return [centerX, centerY];
  653. }
  654.  
  655. function FMCGetScrollHeight( winNode )
  656. {
  657.     var scrollHeight    = null;
  658.     
  659.     if ( winNode.document.scrollHeight )
  660.     {
  661.         scrollHeight = winNode.document.scrollHeight;
  662.     }
  663.     else if ( FMCIsQuirksMode( winNode ) )
  664.     {
  665.         scrollHeight = winNode.document.body.scrollHeight;
  666.     }
  667.     else if ( winNode.document.documentElement )
  668.     {
  669.         scrollHeight = winNode.document.documentElement.scrollHeight;
  670.     }
  671.     
  672.     return scrollHeight;
  673. }
  674.  
  675. function FMCGetScrollWidth( winNode )
  676. {
  677.     var scrollWidth = null;
  678.     
  679.     if ( winNode.document.scrollWidth )
  680.     {
  681.         scrollWidth = winNode.document.scrollWidth;
  682.     }
  683.     else if ( FMCIsQuirksMode( winNode ) )
  684.     {
  685.         scrollWidth = winNode.document.body.scrollWidth;
  686.     }
  687.     else if ( winNode.document.documentElement )
  688.     {
  689.         scrollWidth = winNode.document.documentElement.scrollWidth;
  690.     }
  691.     
  692.     return scrollWidth;
  693. }
  694.  
  695. function FMCGetScrollTop( winNode )
  696. {
  697.     var scrollTop   = null;
  698.     
  699.     if ( FMCIsSafari() )
  700.     {
  701.         scrollTop = winNode.document.body.scrollTop;
  702.     }
  703.     else if ( FMCIsQuirksMode( winNode ) )
  704.     {
  705.         scrollTop = winNode.document.body.scrollTop;
  706.     }
  707.     else if ( winNode.document.documentElement )
  708.     {
  709.         scrollTop = winNode.document.documentElement.scrollTop;
  710.     }
  711.     
  712.     return scrollTop;
  713. }
  714.  
  715. function FMCSetScrollTop( winNode, value )
  716. {
  717.     if ( FMCIsSafari() )
  718.     {
  719.         winNode.document.body.scrollTop = value;
  720.     }
  721.     else if ( FMCIsQuirksMode( winNode ) )
  722.     {
  723.         winNode.document.body.scrollTop = value;
  724.     }
  725.     else if ( winNode.document.documentElement )
  726.     {
  727.         winNode.document.documentElement.scrollTop = value;
  728.     }
  729. }
  730.  
  731. function FMCGetScrollLeft( winNode )
  732. {
  733.     var scrollLeft  = null;
  734.     
  735.     if ( FMCIsSafari() )
  736.     {
  737.         scrollLeft = winNode.document.body.scrollLeft;
  738.     }
  739.     else if ( FMCIsQuirksMode( winNode ) )
  740.     {
  741.         scrollLeft = winNode.document.body.scrollLeft;
  742.     }
  743.     else if ( winNode.document.documentElement )
  744.     {
  745.         scrollLeft = winNode.document.documentElement.scrollLeft;
  746.     }
  747.     
  748.     return scrollLeft;
  749. }
  750.  
  751. function FMCSetScrollLeft( winNode, value )
  752. {
  753.     if ( FMCIsSafari() )
  754.     {
  755.         winNode.document.body.scrollLeft = value;
  756.     }
  757.     else if ( FMCIsQuirksMode( winNode ) )
  758.     {
  759.         winNode.document.body.scrollLeft = value;
  760.     }
  761.     else if ( winNode.document.documentElement )
  762.     {
  763.         winNode.document.documentElement.scrollLeft = value;
  764.     }
  765. }
  766.  
  767. function FMCGetClientX( winNode, e )
  768. {
  769.     var clientX;
  770.     
  771.     if ( typeof( e.pageX ) != "undefined" )
  772.     {
  773.         clientX = e.pageX - FMCGetScrollLeft( winNode );
  774.     }
  775.     else if ( typeof( e.clientX ) != "undefined" )
  776.     {
  777.         clientX = e.clientX;
  778.     }
  779.     
  780.     return clientX;
  781. }
  782.  
  783. function FMCGetClientY( winNode, e )
  784. {
  785.     var clientY;
  786.     
  787.     if ( typeof( e.pageY ) != "undefined" )
  788.     {
  789.         clientY = e.pageY - FMCGetScrollTop( winNode );
  790.     }
  791.     else if ( typeof( e.clientY ) != "undefined" )
  792.     {
  793.         clientY = e.clientY;
  794.     }
  795.     
  796.     return clientY;
  797. }
  798.  
  799. function FMCGetPageX( winNode, e )
  800. {
  801.     var pageX;
  802.     
  803.     if ( typeof( e.pageX ) != "undefined" )
  804.     {
  805.         pageX = e.pageX;
  806.     }
  807.     else if ( typeof( e.clientX ) != "undefined" )
  808.     {
  809.         pageX = e.clientX + FMCGetScrollLeft( winNode );
  810.     }
  811.     
  812.     return pageX;
  813. }
  814.  
  815. function FMCGetPageY( winNode, e )
  816. {
  817.     var pageY;
  818.     
  819.     if ( typeof( e.pageY ) != "undefined" )
  820.     {
  821.         pageY = e.pageY;
  822.     }
  823.     else if ( typeof( e.clientY ) != "undefined" )
  824.     {
  825.         pageY = e.clientY + FMCGetScrollTop( winNode );
  826.     }
  827.     
  828.     return pageY;
  829. }
  830.  
  831. function FMCGetMouseXRelativeTo( winNode, e, el )
  832. {
  833.     var mouseX    = FMCGetPageX( winNode, e, el );
  834.     var elX        = FMCGetPosition( el )[1];
  835.     var x        = mouseX - elX;
  836.  
  837.     return x;
  838. }
  839.  
  840. function FMCGetMouseYRelativeTo( winNode, e, el )
  841. {
  842.     var mouseY    = FMCGetPageY( winNode, e, el );
  843.     var elY        = FMCGetPosition( el )[0];
  844.     var y        = mouseY - elY;
  845.  
  846.     return y;
  847. }
  848.  
  849. function FMCGetPosition( node )
  850. {
  851.     var topPos    = 0;
  852.     var leftPos    = 0;
  853.     
  854.     if ( node.offsetParent )
  855.     {
  856.         topPos = node.offsetTop;
  857.         leftPos = node.offsetLeft;
  858.         
  859.         while ( node = node.offsetParent )
  860.         {
  861.             topPos += node.offsetTop;
  862.             leftPos += node.offsetLeft;
  863.         }
  864.     }
  865.     
  866.     return [topPos, leftPos];
  867. }
  868.  
  869. function FMCScrollToVisible( win, node )
  870. {
  871.     var offset            = 0;
  872.     
  873.     if ( typeof( window.innerWidth ) != "undefined" && !FMCIsSafari() )
  874.     {
  875.         offset = 19;
  876.     }
  877.     
  878.     var scrollTop        = FMCGetScrollTop( win );
  879.     var scrollBottom    = scrollTop + FMCGetClientHeight( win, false ) - offset;
  880.     var scrollLeft        = FMCGetScrollLeft( win );
  881.     var scrollRight        = scrollLeft + FMCGetClientWidth( win, false ) - offset;
  882.     
  883.     var nodePos            = FMCGetPosition( node );
  884.     var nodeTop            = nodePos[0];
  885.     var nodeLeft        = parseInt( node.style.textIndent ) + nodePos[1];
  886.     var nodeHeight        = node.offsetHeight;
  887.     var nodeWidth        = node.getElementsByTagName( "a" )[0].offsetWidth;
  888.     
  889.     if ( nodeTop < scrollTop )
  890.     {
  891.         FMCSetScrollTop( win, nodeTop );
  892.     }
  893.     else if ( nodeTop + nodeHeight > scrollBottom )
  894.     {
  895.         FMCSetScrollTop( win, Math.min( nodeTop, nodeTop + nodeHeight - FMCGetClientHeight( win, false ) + offset ) );
  896.     }
  897.     
  898.     if ( nodeLeft < scrollLeft )
  899.     {
  900.         FMCSetScrollLeft( win, nodeLeft );
  901.     }
  902.     else if ( nodeLeft + nodeWidth > scrollRight )
  903.     {
  904.         FMCSetScrollLeft( win, Math.min( nodeLeft, nodeLeft + nodeWidth - FMCGetClientWidth( win, false ) + offset ) );
  905.     }
  906. }
  907.  
  908. function FMCIsQuirksMode( winNode )
  909. {
  910.     return FMCIsIE55() || (winNode.document.compatMode && winNode.document.compatMode == "BackCompat");
  911. }
  912.  
  913. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  914.  
  915. function FMCGetComputedStyle( node, style )
  916. {
  917.     var value   = null;
  918.     
  919.     if ( node.currentStyle )
  920.     {
  921.         value = node.currentStyle[style];
  922.     }
  923.     else if ( document.defaultView && document.defaultView.getComputedStyle )
  924.     {
  925.         var computedStyle    = document.defaultView.getComputedStyle( node, null );
  926.         
  927.         if ( computedStyle )
  928.         {
  929.             value = computedStyle[style];
  930.         }
  931.     }
  932.     
  933.     return value;
  934. }
  935.  
  936. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  937.  
  938. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  939.  
  940. function FMCConvertToPx( doc, str, dimension, defaultValue )
  941. {
  942.     if ( !str || str.charAt( 0 ) == "-" )
  943.     {
  944.         return defaultValue;
  945.     }
  946.     
  947.     if ( str.charAt( str.length - 1 ) == "\%" )
  948.     {
  949.         switch (dimension)
  950.         {
  951.             case "Width":
  952.                 return parseInt( str ) * screen.width / 100;
  953.                 
  954.                 break;
  955.             case "Height":
  956.                 return parseInt( str ) * screen.height / 100;
  957.                 
  958.                 break;
  959.         }
  960.     }
  961.     else
  962.     {
  963.         if ( parseInt( str ).toString() == str )
  964.         {
  965.             str += "px";
  966.         }
  967.     }
  968.     
  969.     try
  970.     {
  971.         var div    = doc.createElement( "div" );
  972.     }
  973.     catch ( err )
  974.     {
  975.         return defaultValue;
  976.     }
  977.     
  978.     doc.body.appendChild( div );
  979.     
  980.     var value    = defaultValue;
  981.     
  982.     try
  983.     {
  984.         div.style.width = str;
  985.         
  986.         if ( div.currentStyle )
  987.         {
  988.             value = div.offsetWidth;
  989.         }
  990.         else if ( document.defaultView && document.defaultView.getComputedStyle )
  991.         {
  992.             value = parseInt( FMCGetComputedStyle( div, "width" ) );
  993.         }
  994.     }
  995.     catch ( err )
  996.     {
  997.     }
  998.     
  999.     doc.body.removeChild( div );
  1000.     
  1001.     return value;
  1002. }
  1003.  
  1004. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  1005.  
  1006. function FMCGetControl( el )
  1007. {
  1008.     var value    = null;
  1009.     
  1010.     if ( el.type == "checkbox" )
  1011.     {
  1012.         value = el.checked;
  1013.     }
  1014.     else
  1015.     {
  1016.         value = el.value;
  1017.     }
  1018.     
  1019.     return value;
  1020. }
  1021.  
  1022. function FMCGetOpacity( el )
  1023. {
  1024.     var opacity    = -1;
  1025.     
  1026.     if ( el.filters )
  1027.     {
  1028.         opacity = parseInt( el.style.filter.substring( 17, el.style.filter.length - 2 ) );
  1029.     }
  1030.     else if ( el.style.MozOpacity != null )
  1031.     {
  1032.         opacity = parseFloat( el.style.MozOpacity ) * 100;
  1033.     }
  1034.     
  1035.     return opacity;
  1036. }
  1037.  
  1038. function FMCSetOpacity( el, opacityPercent )
  1039. {
  1040.     if ( el.filters )
  1041.     {
  1042.         // IE bug: If a text input field is contained within an element that has an opacity set and it contains too much text to fit inside it,
  1043.         // using the keyboard to move the cursor to scroll the text will result in the text not "refreshing" in the text input field.
  1044.         // The workaround is to set the opacity to "" in IE when it becomes 100. That way, the cursor issue will be fixed inside our dialogs
  1045.         // which fade in to 100% opacity when they're opened.
  1046.         
  1047.         if ( opacityPercent == 100 )
  1048.         {
  1049.             el.style.filter = "";
  1050.         }
  1051.         else
  1052.         {
  1053.             el.style.filter = "alpha( opacity = " + opacityPercent + " )";
  1054.         }
  1055.     }
  1056.     else if ( el.style.MozOpacity != null )
  1057.     {
  1058.         el.style.MozOpacity = opacityPercent / 100;
  1059.     }
  1060. }
  1061.  
  1062. function FMCToggleDisplay( el )
  1063. {
  1064.     if ( el.style.display == "none" )
  1065.     {
  1066.         el.style.display = "";
  1067.     }
  1068.     else
  1069.     {
  1070.         el.style.display = "none";
  1071.     }
  1072. }
  1073.  
  1074. function FMCGetContainingIFrame( win )
  1075. {
  1076.     var allIFrames = win.parent.document.getElementsByTagName( "iframe" );
  1077.     
  1078.     for ( var i = 0, length = allIFrames.length; i < length; i++ )
  1079.     {
  1080.         var currIFrame = allIFrames[i];
  1081.         
  1082.         if ( FMCGetAttribute( currIFrame, "name" ) == win.name )
  1083.         {
  1084.             return currIFrame;
  1085.         }
  1086.     }
  1087.     
  1088.     return null;
  1089. }
  1090.  
  1091. function FMCIsChildNode( childNode, parentNode )
  1092. {
  1093.     var    doc    = parentNode.ownerDocument;
  1094.     
  1095.     if ( childNode == null )
  1096.     {
  1097.         return null;
  1098.     }
  1099.     
  1100.     for ( var currNode = childNode; ; currNode = currNode.parentNode )
  1101.     {
  1102.         if ( currNode == parentNode )
  1103.         {
  1104.             return true;
  1105.         }
  1106.         
  1107.         if ( currNode == doc.body )
  1108.         {
  1109.             return false;
  1110.         }
  1111.     }
  1112. }
  1113.  
  1114. function FMCIsInDom( el )
  1115. {
  1116.     var isInDom = false;
  1117.     
  1118.     // Accessing el.offsetParent when the element isn't in the DOM might throw an exception.
  1119.     
  1120.     try
  1121.     {
  1122.         isInDom = el.offsetParent != null;
  1123.     }
  1124.     catch ( ex )
  1125.     {
  1126.     }
  1127.     
  1128.     return isInDom;
  1129. }
  1130.  
  1131. function FMCStripCssUrl( url )
  1132. {
  1133.     if ( !url )
  1134.     {
  1135.         return null;
  1136.     }
  1137.     
  1138.     var regex    = /url\(\s*(['\"]?)([^'\"\s]*)\1\s*\)/;
  1139.     var match    = regex.exec( url );
  1140.     
  1141.     if ( match )
  1142.     {
  1143.         return match[2];
  1144.     }
  1145.     
  1146.     return null;
  1147. }
  1148.  
  1149. function FMCCreateCssUrl( path )
  1150. {
  1151.     return "url(\"" + path + "\")";
  1152. }
  1153.  
  1154. function FMCGetPropertyValue( propertyNode, defaultValue )
  1155. {
  1156.     var propValue    = defaultValue;
  1157.     var valueNode    = propertyNode.firstChild;
  1158.     
  1159.     if ( valueNode )
  1160.     {
  1161.         propValue = valueNode.nodeValue;
  1162.     }
  1163.     
  1164.     return propValue;
  1165. }
  1166.  
  1167. function FMCParseInt( str, defaultValue )
  1168. {
  1169.     var num    = parseInt( str );
  1170.  
  1171.     if ( num.toString() == "NaN" )
  1172.     {
  1173.         num = defaultValue;
  1174.     }
  1175.     
  1176.     return num;
  1177. }
  1178.  
  1179. function FMCConvertBorderToPx( doc, value )
  1180. {
  1181.     var newValue    = "";
  1182.     var valueParts    = value.split( " " );
  1183.  
  1184.     for ( var i = 0; i < valueParts.length; i++ )
  1185.     {
  1186.         var currPart    = valueParts[i];
  1187.         
  1188.         if ( i == 1 )
  1189.         {
  1190.             currPart = FMCConvertToPx( doc, currPart, null, currPart );
  1191.             
  1192.             if ( parseInt( currPart ).toString() == currPart )
  1193.             {
  1194.                 currPart += "px";
  1195.             }
  1196.         }
  1197.  
  1198.         if ( !String.IsNullOrEmpty( currPart ) )
  1199.         {
  1200.             newValue += (((i > 0) ? " " : "") + currPart);
  1201.         }
  1202.     }
  1203.     
  1204.     return newValue;
  1205. }
  1206.  
  1207. function FMCUnhide( win, node )
  1208. {
  1209.     for ( var currNode = node.parentNode; currNode.nodeName != "BODY"; currNode = currNode.parentNode )
  1210.     {
  1211.         if ( currNode.style.display == "none" )
  1212.         {
  1213.             var classRoot   = FMCContainsClassRoot( currNode.className, "MCExpandingBody", "MCDropDownBody", "MCTextPopupBody" );
  1214.             
  1215.             if ( classRoot == "MCExpandingBody" )
  1216.             {
  1217.                 win.FMCExpand( currNode.parentNode.getElementsByTagName("a")[0] );
  1218.             }
  1219.             else if ( classRoot == "MCDropDownBody" )
  1220.             {
  1221.                 var dropDownBodyID  = currNode.id.substring( "MCDropDownBody".length + 1, currNode.id.length );
  1222.                 var aNodes          = currNode.parentNode.getElementsByTagName( "a" );
  1223.                 
  1224.                 for ( var i = 0; i < aNodes.length; i++ )
  1225.                 {
  1226.                     var aNode   = aNodes[i];
  1227.                     
  1228.                     if ( aNode.id.substring( "MCDropDownHotSpot".length + 1, aNode.id.length ) == dropDownBodyID )
  1229.                     {
  1230.                         win.FMCDropDown( aNode );
  1231.                     }
  1232.                 }
  1233.             }
  1234.             else if ( FMCGetMCAttribute( currNode, "MadCap:targetName" ) )
  1235.             {
  1236.                 var targetName      = FMCGetMCAttribute( currNode, "MadCap:targetName" );
  1237.                 var togglerNodes    = FMCGetElementsByClassRoot( win.document.body, "MCToggler" );
  1238.                 
  1239.                 for ( var i = 0; i < togglerNodes.length; i++ )
  1240.                 {
  1241.                     var targets = FMCGetMCAttribute( togglerNodes[i], "MadCap:targets" ).split( ";" );
  1242.                     var found   = false;
  1243.                     
  1244.                     for ( var j = 0; j < targets.length; j++ )
  1245.                     {
  1246.                         if ( targets[j] == targetName )
  1247.                         {
  1248.                             found = true;
  1249.                             
  1250.                             break;
  1251.                         }
  1252.                     }
  1253.                     
  1254.                     if ( !found )
  1255.                     {
  1256.                         continue;
  1257.                     }
  1258.                     
  1259.                     win.FMCToggler( togglerNodes[i] );
  1260.                     
  1261.                     break;
  1262.                 }
  1263.             }
  1264.             else if ( classRoot == "MCTextPopupBody" )
  1265.             {
  1266.                 continue;
  1267.             }
  1268.             else if ( currNode.className == "MCWebHelpFramesetLink" )
  1269.             {
  1270.                 continue;
  1271.             }
  1272.             else
  1273.             {
  1274.                 currNode.style.display = "";
  1275.             }
  1276.         }
  1277.     }
  1278. }
  1279.  
  1280. function StartLoading( win, parentElement, loadingLabel, loadingAltText, fadeElement )
  1281. {
  1282.     if ( !win.MCLoadingCount )
  1283.     {
  1284.         win.MCLoadingCount = 0;
  1285.     }
  1286.     
  1287.     win.MCLoadingCount++;
  1288.     
  1289.     if ( win.MCLoadingCount > 1 )
  1290.     {
  1291.         return;
  1292.     }
  1293.     
  1294.     //
  1295.     
  1296.     if ( fadeElement )
  1297.     {
  1298.         // IE bug: This causes the tab outline not to show and also causes the TOC entry fonts to look bold.
  1299.         //    if ( fadeElement.filters )
  1300.         //    {
  1301.         //        fadeElement.style.filter = "alpha( opacity = 10 )";
  1302.         //    }
  1303.         /*else*/ if ( fadeElement.style.MozOpacity != null )
  1304.         {
  1305.             fadeElement.style.MozOpacity = "0.1";
  1306.         }
  1307.     }
  1308.  
  1309.     var span        = win.document.createElement( "span" );
  1310.     var img            = win.document.createElement( "img" );
  1311.     var midPointX    = FMCGetScrollLeft( win ) + FMCGetClientWidth( win, false ) / 2;
  1312.     var spacing        = 3;
  1313.  
  1314.     parentElement.appendChild( span );
  1315.  
  1316.     span.id = "LoadingText";
  1317.     span.appendChild( win.document.createTextNode( loadingLabel ) );
  1318.     span.style.fontFamily = "Tahoma, Sans-Serif";
  1319.     span.style.fontSize = "9px";
  1320.     span.style.fontWeight = "bold";
  1321.     span.style.position = "absolute";
  1322.     span.style.left = (midPointX - (span.offsetWidth / 2)) + "px";
  1323.  
  1324.     var rootFrame    = FMCGetRootFrame();
  1325.     
  1326.     img.id = "LoadingImage";
  1327.     img.src = rootFrame.gRootFolder + MCGlobals.SkinTemplateFolder + "Images/Loading.gif";
  1328.     img.alt = loadingAltText;
  1329.     img.style.width = "70px";
  1330.     img.style.height = "13px";
  1331.     img.style.position = "absolute";
  1332.     img.style.left = (midPointX - (70/2)) + "px";
  1333.  
  1334.     var totalHeight    = span.offsetHeight + spacing + parseInt( img.style.height );
  1335.     var spanTop        = (FMCGetScrollTop( win ) + (FMCGetClientHeight( win, false ) - totalHeight)) / 2;
  1336.  
  1337.     span.style.top = spanTop + "px";
  1338.     img.style.top = spanTop + span.offsetHeight + spacing + "px";
  1339.  
  1340.     parentElement.appendChild( img );
  1341. }
  1342.  
  1343. function EndLoading( win, fadeElement )
  1344. {
  1345.     win.MCLoadingCount--;
  1346.     
  1347.     if ( win.MCLoadingCount > 0 )
  1348.     {
  1349.         return;
  1350.     }
  1351.     
  1352.     //
  1353.     
  1354.     var span    = win.document.getElementById( "LoadingText" );
  1355.     var img        = win.document.getElementById( "LoadingImage" );
  1356.  
  1357.     span.parentNode.removeChild( span );
  1358.     img.parentNode.removeChild( img );
  1359.  
  1360.     if ( fadeElement )
  1361.     {
  1362.         // IE bug: This causes the tab outline not to show and also causes the TOC entry fonts to look bold.
  1363.         //    if ( fadeElement.filters )
  1364.         //    {
  1365.         //        fadeElement.style.filter = "alpha( opacity = 100 )";
  1366.         //    }
  1367.         /*else*/ if ( fadeElement.style.MozOpacity != null )
  1368.         {
  1369.             fadeElement.style.MozOpacity = "1.0";
  1370.         }
  1371.     }
  1372. }
  1373.  
  1374. var MCEventType    = new Object();
  1375.  
  1376. MCEventType.OnLoad    = 0;
  1377. MCEventType.OnInit    = 1;
  1378. MCEventType.OnReady    = 2;
  1379.  
  1380. function FMCRegisterCallback( frameName, eventType, CallbackFunc, callbackArgs )
  1381. {
  1382.     function FMCCheckMCGlobalsInitialized()
  1383.     {
  1384.         if ( MCGlobals.Initialized )
  1385.         {
  1386.             CallbackFunc( callbackArgs );
  1387.         }
  1388.         else
  1389.         {
  1390.             setTimeout( FMCCheckMCGlobalsInitialized, 100 );
  1391.         }
  1392.     }
  1393.  
  1394.     function FMCCheckRootReady()
  1395.     {
  1396.         if ( MCGlobals.RootFrame.gReady )
  1397.         {
  1398.             CallbackFunc( callbackArgs );
  1399.         }
  1400.         else
  1401.         {
  1402.             setTimeout( FMCCheckRootReady, 100 );
  1403.         }
  1404.     }
  1405.  
  1406.     function FMCCheckRootLoaded()
  1407.     {
  1408.         if ( MCGlobals.RootFrame.gLoaded )
  1409.         {
  1410.             CallbackFunc( callbackArgs );
  1411.         }
  1412.         else
  1413.         {
  1414.             setTimeout( FMCCheckRootLoaded, 100 );
  1415.         }
  1416.     }
  1417.  
  1418.     function FMCCheckTOCInitialized()
  1419.     {
  1420.         if ( MCGlobals.NavigationFrame.frames["toc"].gInit )
  1421.         {
  1422.             CallbackFunc( callbackArgs );
  1423.         }
  1424.         else
  1425.         {
  1426.             setTimeout( FMCCheckTOCInitialized, 100 );
  1427.         }
  1428.     }
  1429.  
  1430.     function FMCCheckSearchInitialized()
  1431.     {
  1432.         if ( MCGlobals.NavigationFrame.frames["search"].gInit )
  1433.         {
  1434.             CallbackFunc( callbackArgs );
  1435.         }
  1436.         else
  1437.         {
  1438.             setTimeout( FMCCheckSearchInitialized, 100 );
  1439.         }
  1440.     }
  1441.  
  1442.     function FMCCheckBodyCommentsLoaded()
  1443.     {
  1444.         if ( MCGlobals.BodyCommentsFrame.gLoaded )
  1445.         {
  1446.             CallbackFunc( callbackArgs );
  1447.         }
  1448.         else
  1449.         {
  1450.             setTimeout( FMCCheckBodyCommentsLoaded, 100 );
  1451.         }
  1452.     }
  1453.  
  1454.     function FMCCheckBodyCommentsInitialized()
  1455.     {
  1456.         if ( MCGlobals.BodyCommentsFrame.gInit )
  1457.         {
  1458.             CallbackFunc( callbackArgs );
  1459.         }
  1460.         else
  1461.         {
  1462.             setTimeout( FMCCheckBodyCommentsInitialized, 100 );
  1463.         }
  1464.     }
  1465.  
  1466.     function FMCCheckToolbarInitialized()
  1467.     {
  1468.         if ( MCGlobals.ToolbarFrame.gInit )
  1469.         {
  1470.             CallbackFunc( callbackArgs );
  1471.         }
  1472.         else
  1473.         {
  1474.             setTimeout( FMCCheckToolbarInitialized, 100 );
  1475.         }
  1476.     }
  1477.  
  1478.     function FMCCheckNavigationReady()
  1479.     {
  1480.         if ( MCGlobals.NavigationFrame.gReady )
  1481.         {
  1482.             CallbackFunc( callbackArgs );
  1483.         }
  1484.         else
  1485.         {
  1486.             setTimeout( FMCCheckNavigationReady, 100 );
  1487.         }
  1488.     }
  1489.  
  1490.     function FMCCheckNavigationLoaded()
  1491.     {
  1492.         if ( MCGlobals.NavigationFrame.gLoaded )
  1493.         {
  1494.             CallbackFunc( callbackArgs );
  1495.         }
  1496.         else
  1497.         {
  1498.             setTimeout( FMCCheckNavigationLoaded, 100 );
  1499.         }
  1500.     }
  1501.  
  1502.     function FMCCheckBodyReady()
  1503.     {
  1504.         if ( typeof( MCGlobals.BodyFrame.gReady ) == "undefined" || MCGlobals.BodyFrame.gReady )
  1505.         {
  1506.             CallbackFunc( callbackArgs );
  1507.         }
  1508.         else
  1509.         {
  1510.             setTimeout( FMCCheckBodyReady, 100 );
  1511.         }
  1512.     }
  1513.  
  1514.     function FMCCheckBodyLoaded()
  1515.     {
  1516.         if ( MCGlobals.BodyFrame.gLoaded )
  1517.         {
  1518.             CallbackFunc( callbackArgs );
  1519.         }
  1520.         else
  1521.         {
  1522.             setTimeout( FMCCheckBodyLoaded, 100 );
  1523.         }
  1524.     }
  1525.     
  1526.     function FMCCheckBodyInitialized()
  1527.     {
  1528.         if ( MCGlobals.BodyFrame.gInit )
  1529.         {
  1530.             CallbackFunc( callbackArgs );
  1531.         }
  1532.         else
  1533.         {
  1534.             setTimeout( FMCCheckBodyInitialized, 100 );
  1535.         }
  1536.     }
  1537.  
  1538.     function FMCCheckPersistenceInitialized()
  1539.     {
  1540.         if ( MCGlobals.PersistenceFrame.gInit )
  1541.         {
  1542.             CallbackFunc( callbackArgs );
  1543.         }
  1544.         else
  1545.         {
  1546.             setTimeout( FMCCheckPersistenceInitialized, 100 );
  1547.         }
  1548.     }
  1549.     
  1550.     var func    = null;
  1551.     
  1552.     if ( frameName == "TOC" )
  1553.     {
  1554.         if ( eventType == MCEventType.OnLoad ) { func = FMCCheckTOCLoaded; }
  1555.         else if ( eventType == MCEventType.OnInit ) { func = FMCCheckTOCInitialized; }
  1556.         else if ( eventType == MCEventType.OnReady ) { func = FMCCheckTOCReady; }
  1557.     }
  1558.     else if ( frameName == "Toolbar" )
  1559.     {
  1560.         if ( eventType == MCEventType.OnLoad ) { func = FMCCheckToolbarLoaded; }
  1561.         else if ( eventType == MCEventType.OnInit ) { func = FMCCheckToolbarInitialized; }
  1562.         else if ( eventType == MCEventType.OnReady ) { func = FMCCheckToolbarReady; }
  1563.     }
  1564.     else if ( frameName == "BodyComments" )
  1565.     {
  1566.         if ( eventType == MCEventType.OnLoad ) { func = FMCCheckBodyCommentsLoaded; }
  1567.         else if ( eventType == MCEventType.OnInit ) { func = FMCCheckBodyCommentsInitialized; }
  1568.         else if ( eventType == MCEventType.OnReady ) { func = FMCCheckBodyCommentsReady; }
  1569.     }
  1570.     else if ( frameName == "Persistence" )
  1571.     {
  1572.         if ( eventType == MCEventType.OnLoad ) { func = FMCCheckPersistenceLoaded; }
  1573.         else if ( eventType == MCEventType.OnInit ) { func = FMCCheckPersistenceInitialized; }
  1574.         else if ( eventType == MCEventType.OnReady ) { func = FMCCheckPersistenceReady; }
  1575.     }
  1576.     else if ( frameName == "Search" )
  1577.     {
  1578.         if ( eventType == MCEventType.OnLoad ) { func = FMCCheckSearchLoaded; }
  1579.         else if ( eventType == MCEventType.OnInit ) { func = FMCCheckSearchInitialized; }
  1580.         else if ( eventType == MCEventType.OnReady ) { func = FMCCheckSearchReady; }
  1581.     }
  1582.     else if ( frameName == "MCGlobals" )
  1583.     {
  1584.         if ( eventType == MCEventType.OnLoad ) { func = FMCCheckMCGlobalsLoaded; }
  1585.         else if ( eventType == MCEventType.OnInit ) { func = FMCCheckMCGlobalsInitialized; }
  1586.         else if ( eventType == MCEventType.OnReady ) { func = FMCCheckMCGlobalsReady; }
  1587.     }
  1588.     else if ( frameName == "Navigation" )
  1589.     {
  1590.         if ( eventType == MCEventType.OnLoad ) { func = FMCCheckNavigationLoaded; }
  1591.         else if ( eventType == MCEventType.OnInit ) { func = FMCCheckNavigationInitialized; }
  1592.         else if ( eventType == MCEventType.OnReady ) { func = FMCCheckNavigationReady; }
  1593.     }
  1594.     else if ( frameName == "Body" )
  1595.     {
  1596.         if ( eventType == MCEventType.OnLoad ) { func = FMCCheckBodyLoaded; }
  1597.         else if ( eventType == MCEventType.OnInit ) { func = FMCCheckBodyInitialized; }
  1598.         else if ( eventType == MCEventType.OnReady ) { func = FMCCheckBodyReady; }
  1599.     }
  1600.     else if ( frameName == "Root" )
  1601.     {
  1602.         if ( eventType == MCEventType.OnLoad ) { func = FMCCheckRootLoaded; }
  1603.         else if ( eventType == MCEventType.OnInit ) { func = FMCCheckRootInitialized; }
  1604.         else if ( eventType == MCEventType.OnReady ) { func = FMCCheckRootReady; }
  1605.     }
  1606.     
  1607.     window.setTimeout( func, 100 );
  1608. }
  1609.  
  1610. function FMCSortStringArray( stringArray )
  1611. {
  1612.     stringArray.sort( FMCCompareStrings );
  1613. }
  1614.  
  1615. function FMCCompareStrings( a, b )
  1616. {
  1617.     var ret;
  1618.  
  1619.     if ( a.toLowerCase() < b.toLowerCase() )
  1620.     {
  1621.         ret = -1;
  1622.     }
  1623.     else if ( a.toLowerCase() == b.toLowerCase() )
  1624.     {
  1625.         ret = 0;
  1626.     }
  1627.     else if ( a.toLowerCase() > b.toLowerCase() )
  1628.     {
  1629.         ret = 1;
  1630.     }
  1631.  
  1632.     return ret;
  1633. }
  1634.  
  1635. function FMCSetCookie( name, value, days )
  1636. {
  1637.     if ( window.name != "bridge" )
  1638.     {
  1639.         if (!FMCIsDotNetHelp())
  1640.         {
  1641.             if (window != MCGlobals.NavigationFrame)
  1642.             {
  1643.                 MCGlobals.NavigationFrame.FMCSetCookie(name, value, days);
  1644.  
  1645.                 return;
  1646.             } 
  1647.         }
  1648.     }
  1649.     
  1650.     value = encodeURI( value );
  1651.     
  1652.     var expires = null;
  1653.     
  1654.     if ( days )
  1655.     {
  1656.         var date    = new Date();
  1657.         
  1658.         date.setTime( date.getTime() + (1000 * 60 * 60 * 24 * days) );
  1659.         
  1660.         expires = "; expires=" + date.toGMTString();
  1661.     }
  1662.     else
  1663.     {
  1664.         expires = "";
  1665.     }
  1666.  
  1667. //    var rootFrame    = FMCGetRootFrame();
  1668. //    var navFrame    = rootFrame.frames["navigation"];
  1669. //    var path        = FMCGetPathnameFolder( navFrame.document.location );
  1670.  
  1671. //    navFrame.document.cookie = name + "=" + value + expires + ";" + " path=" + path + ";";
  1672.  
  1673.     var cookieString = name + "=" + value + expires + ";";
  1674.     
  1675.     document.cookie = cookieString;
  1676. }
  1677.  
  1678. function FMCReadCookie( name )
  1679. {
  1680.     if ( window.name != "bridge" )
  1681.     {
  1682.         if (!FMCIsDotNetHelp())
  1683.         {
  1684.             if (window != MCGlobals.NavigationFrame)
  1685.             {
  1686.                 return MCGlobals.NavigationFrame.FMCReadCookie(name);
  1687.             } 
  1688.         }
  1689.     }
  1690.     
  1691.     var value        = null;
  1692.     var nameEq        = name + "=";
  1693. //    var rootFrame    = FMCGetRootFrame();
  1694. //    var navFrame    = rootFrame.frames["navigation"];
  1695. //    var cookies        = navFrame.document.cookie.split( ";" );
  1696.     var cookies        = document.cookie.split( ";" );
  1697.  
  1698.     for ( var i = 0; i < cookies.length; i++ )
  1699.     {
  1700.         var cookie    = cookies[i];
  1701.         
  1702.         cookie = FMCTrim( cookie );
  1703.         
  1704.         if ( cookie.indexOf( nameEq ) == 0 )
  1705.         {
  1706.             value = cookie.substring( nameEq.length, cookie.length );
  1707.             value = decodeURI( value );
  1708.             
  1709.             break;
  1710.         }
  1711.     }
  1712.  
  1713.     return value;
  1714. }
  1715.  
  1716. function FMCRemoveCookie( name )
  1717. {
  1718.     FMCSetCookie( name, "", -1 );
  1719. }
  1720.  
  1721. function FMCLoadUserData( name )
  1722. {
  1723.     if ( FMCIsHtmlHelp() )
  1724.     {
  1725.         var persistFrame    = MCGlobals.PersistenceFrame;
  1726.         var persistDiv        = persistFrame.document.getElementById( "Persist" );
  1727.         
  1728.         persistDiv.load( "MCXMLStore" );
  1729.         
  1730.         var value    = persistDiv.getAttribute( name );
  1731.         
  1732.         return value;
  1733.     }
  1734.     else
  1735.     {
  1736.         return FMCReadCookie( name );
  1737.     }
  1738. }
  1739.  
  1740. function FMCSaveUserData( name, value )
  1741. {
  1742.     if ( FMCIsHtmlHelp() )
  1743.     {
  1744.         var persistFrame    = MCGlobals.PersistenceFrame;
  1745.         var persistDiv        = persistFrame.document.getElementById( "Persist" );
  1746.         
  1747.         persistDiv.setAttribute( name, value );
  1748.         persistDiv.save( "MCXMLStore" );
  1749.     }
  1750.     else
  1751.     {
  1752.         FMCSetCookie( name, value, 36500 );
  1753.     }
  1754. }
  1755.  
  1756. function FMCRemoveUserData( name )
  1757. {
  1758.     if ( FMCIsHtmlHelp() )
  1759.     {
  1760.         var persistFrame    = MCGlobals.PersistenceFrame;
  1761.         var persistDiv        = persistFrame.document.getElementById( "Persist" );
  1762.         
  1763.         persistDiv.removeAttribute( name );
  1764.         persistDiv.save( "MCXMLStore" );
  1765.     }
  1766.     else
  1767.     {
  1768.         FMCRemoveCookie( name );
  1769.     }
  1770. }
  1771.  
  1772. function FMCInsertOpacitySheet( winNode, color )
  1773. {
  1774.     if ( winNode.document.getElementById( "MCOpacitySheet" ) != null )
  1775.     {
  1776.         return;
  1777.     }
  1778.     
  1779.     var div        = winNode.document.createElement( "div" );
  1780.     var style    = div.style;
  1781.     
  1782.     div.id = "MCOpacitySheet";
  1783.     style.position = "absolute";
  1784.     style.top = FMCGetScrollTop( winNode ) + "px";
  1785.     style.left = FMCGetScrollLeft( winNode ) + "px";
  1786.     style.width = FMCGetClientWidth( winNode, false ) + "px";
  1787.     style.height = FMCGetClientHeight( winNode, false ) + "px";
  1788.     style.backgroundColor = color;
  1789.     style.zIndex = "100";
  1790.     
  1791.     winNode.document.body.appendChild( div );
  1792.     
  1793.     FMCSetOpacity( div, 75 );
  1794. }
  1795.  
  1796. function FMCRemoveOpacitySheet( winNode )
  1797. {
  1798.     var div    = winNode.document.getElementById( "MCOpacitySheet" );
  1799.     
  1800.     if ( !div )
  1801.     {
  1802.         return;
  1803.     }
  1804.     
  1805.     div.parentNode.removeChild( div );
  1806. }
  1807.  
  1808. function FMCSetupButtonFromStylesheet( tr, styleName, styleClassName, defaultOutPath, defaultOverPath, defaultSelectedPath, defaultWidth, defaultHeight, defaultTooltip, defaultLabel, OnClickHandler )
  1809. {
  1810.     var td                    = document.createElement( "td" );
  1811.     var outImagePath        = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "Icon", null );
  1812.     var overImagePath        = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "HoverIcon", null );
  1813.     var selectedImagePath    = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "PressedIcon", null );
  1814.     
  1815.     if ( outImagePath == null )
  1816.     {
  1817.         outImagePath = defaultOutPath;
  1818.     }
  1819.     else
  1820.     {
  1821.         outImagePath = FMCStripCssUrl( outImagePath );
  1822.         outImagePath = FMCGetSkinFolderAbsolute() + outImagePath;
  1823.     }
  1824.     
  1825.     if ( overImagePath == null )
  1826.     {
  1827.         overImagePath = defaultOverPath;
  1828.     }
  1829.     else
  1830.     {
  1831.         overImagePath = FMCStripCssUrl( overImagePath );
  1832.         overImagePath = FMCGetSkinFolderAbsolute() + overImagePath;
  1833.     }
  1834.     
  1835.     if ( selectedImagePath == null )
  1836.     {
  1837.         selectedImagePath = defaultSelectedPath;
  1838.     }
  1839.     else
  1840.     {
  1841.         selectedImagePath = FMCStripCssUrl( selectedImagePath );
  1842.         selectedImagePath = FMCGetSkinFolderAbsolute() + selectedImagePath;
  1843.     }
  1844.  
  1845.     tr.appendChild( td );
  1846.     
  1847.     var title    = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "Tooltip", defaultTooltip );
  1848.     var label    = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "Label", defaultLabel );
  1849.     var width    = CMCFlareStylesheet.GetResourceProperty( outImagePath, "Width", defaultWidth );
  1850.     var height    = CMCFlareStylesheet.GetResourceProperty( outImagePath, "Height", defaultHeight );
  1851.     
  1852.     MakeButton( td, title, outImagePath, overImagePath, selectedImagePath, width, height, label );
  1853.     td.firstChild.onclick = OnClickHandler;
  1854. }
  1855.  
  1856. function FMCEscapeRegEx( str )
  1857. {
  1858.     return str.replace( /([*^$+?.()[\]{}|\\])/g, "\\$1" );
  1859. }
  1860.  
  1861. //
  1862. //    End helper functions
  1863. //
  1864.  
  1865. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  1866.  
  1867. //
  1868. //    Class CMCXmlParser
  1869. //
  1870.  
  1871. function CMCXmlParser( args, LoadFunc )
  1872. {
  1873.     // Private member variables and functions
  1874.     
  1875.     var mSelf        = this;
  1876.     this.mXmlDoc    = null;
  1877.     this.mXmlHttp    = null;
  1878.     this.mArgs        = args;
  1879.     this.mLoadFunc    = LoadFunc;
  1880.     
  1881.     this.OnreadystatechangeLocal    = function()
  1882.     {
  1883.         if ( mSelf.mXmlDoc.readyState == 4 )
  1884.         {
  1885.             mSelf.mLoadFunc( mSelf.mXmlDoc, mSelf.mArgs );
  1886.         }
  1887.     };
  1888.     
  1889.     this.OnreadystatechangeRemote    = function()
  1890.     {
  1891.         if ( mSelf.mXmlHttp.readyState == 4 )
  1892.         {
  1893.             mSelf.mLoadFunc( mSelf.mXmlHttp.responseXML, mSelf.mArgs );
  1894.         }
  1895.     };
  1896. }
  1897.  
  1898. CMCXmlParser.prototype.LoadLocal    = function( xmlFile, async )
  1899. {
  1900.     if ( window.ActiveXObject )
  1901.     {
  1902.         this.mXmlDoc = CMCXmlParser.GetMicrosoftXmlDomObject();
  1903.         this.mXmlDoc.async = async;
  1904.         
  1905.         if ( this.mLoadFunc )
  1906.         {
  1907.             this.mXmlDoc.onreadystatechange = this.OnreadystatechangeLocal;
  1908.         }
  1909.         
  1910.         try
  1911.         {
  1912.             if ( !this.mXmlDoc.load( xmlFile ) )
  1913.             {
  1914.                 this.mXmlDoc = null;
  1915.             }
  1916.         }
  1917.         catch ( err )
  1918.         {
  1919.             this.mXmlDoc = null;
  1920.         }
  1921.     }
  1922.     else if ( window.XMLHttpRequest )
  1923.     {
  1924.         this.LoadRemote( xmlFile, async ); // window.XMLHttpRequest also works on local files
  1925.     }
  1926.  
  1927.     return this.mXmlDoc;
  1928. };
  1929.  
  1930. CMCXmlParser.prototype.LoadRemote    = function( xmlFile, async )
  1931. {
  1932.     if ( window.ActiveXObject )
  1933.     {
  1934.         this.mXmlHttp = CMCXmlParser.GetMicrosoftXmlHttpObject();
  1935.     }
  1936.     else if ( window.XMLHttpRequest )
  1937.     {
  1938.         xmlFile = xmlFile.replace( /;/g, "%3B" );   // For Safari
  1939.         this.mXmlHttp = new XMLHttpRequest();
  1940.     }
  1941.     
  1942.     if ( this.mLoadFunc )
  1943.     {
  1944.         this.mXmlHttp.onreadystatechange = this.OnreadystatechangeRemote;
  1945.     }
  1946.     
  1947.     try
  1948.     {
  1949.         this.mXmlHttp.open( "GET", xmlFile, async );
  1950.         this.mXmlHttp.send( null );
  1951.         
  1952.         if ( !async && (this.mXmlHttp.status == 0 || this.mXmlHttp.status == 200) )
  1953.         {
  1954.             this.mXmlDoc = this.mXmlHttp.responseXML;
  1955.         }
  1956.     }
  1957.     catch ( err )
  1958.     {
  1959.         this.mXmlHttp.abort();
  1960.     }
  1961.     
  1962.     return this.mXmlDoc;
  1963. };
  1964.  
  1965. // Public member functions
  1966.  
  1967. CMCXmlParser.prototype.Load    = function( xmlFile, async )
  1968. {
  1969.     var xmlDoc            = null;
  1970.     var protocolType    = document.location.protocol;
  1971.     
  1972.     if ( protocolType == "file:" || protocolType == "mk:" || protocolType == "app:" )
  1973.     {
  1974.         xmlDoc = this.LoadLocal( xmlFile, async );
  1975.     }
  1976.     else if ( protocolType == "http:" || protocolType == "https:" )
  1977.     {
  1978.         xmlDoc = this.LoadRemote( xmlFile, async );
  1979.     }
  1980.     
  1981.     return xmlDoc;
  1982. };
  1983.  
  1984. // Static properties
  1985.  
  1986. CMCXmlParser.MicrosoftXmlDomProgIDs = [ "Msxml2.DOMDocument.6.0", "Msxml2.DOMDocument", "Microsoft.XMLDOM" ];
  1987. CMCXmlParser.MicrosoftXmlHttpProgIDs = [ "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP" ];
  1988. CMCXmlParser.MicrosoftXmlDomProgID = null;
  1989. CMCXmlParser.MicrosoftXmlHttpProgID = null;
  1990.  
  1991. // Static member functions
  1992.  
  1993. CMCXmlParser.GetMicrosoftXmlDomObject = function()
  1994. {
  1995.     var obj = null;
  1996.     
  1997.     if ( CMCXmlParser.MicrosoftXmlDomProgID == null )
  1998.     {
  1999.         for ( var i = 0; i < CMCXmlParser.MicrosoftXmlDomProgIDs.length; i++ )
  2000.         {
  2001.             var progID = CMCXmlParser.MicrosoftXmlDomProgIDs[i];
  2002.             
  2003.             try
  2004.             {
  2005.                 obj = new ActiveXObject( progID );
  2006.                 
  2007.                 CMCXmlParser.MicrosoftXmlDomProgID = progID;
  2008.                 
  2009.                 break;
  2010.             }
  2011.             catch ( ex )
  2012.             {
  2013.             }
  2014.         }
  2015.     }
  2016.     else
  2017.     {
  2018.         obj = new ActiveXObject( CMCXmlParser.MicrosoftXmlDomProgID );
  2019.     }
  2020.     
  2021.     return obj;
  2022. };
  2023.  
  2024. CMCXmlParser.GetMicrosoftXmlHttpObject = function()
  2025. {
  2026.     var obj = null;
  2027.     
  2028.     if ( CMCXmlParser.MicrosoftXmlHttpProgID == null )
  2029.     {
  2030.         for ( var i = 0; i < CMCXmlParser.MicrosoftXmlHttpProgIDs.length; i++ )
  2031.         {
  2032.             var progID = CMCXmlParser.MicrosoftXmlHttpProgIDs[i];
  2033.             
  2034.             try
  2035.             {
  2036.                 obj = new ActiveXObject( progID );
  2037.                 
  2038.                 CMCXmlParser.MicrosoftXmlHttpProgID = progID;
  2039.                 
  2040.                 break;
  2041.             }
  2042.             catch ( ex )
  2043.             {
  2044.             }
  2045.         }
  2046.     }
  2047.     else
  2048.     {
  2049.         obj = new ActiveXObject( CMCXmlParser.MicrosoftXmlHttpProgID );
  2050.     }
  2051.     
  2052.     return obj;
  2053. };
  2054.  
  2055. CMCXmlParser.GetXmlDoc    = function( xmlFile, async, LoadFunc, args )
  2056. {
  2057.     var xmlParser    = new CMCXmlParser( args, LoadFunc );
  2058.     var xmlDoc        = xmlParser.Load( xmlFile, async );
  2059.     
  2060.     return xmlDoc;
  2061. }
  2062.  
  2063. CMCXmlParser.LoadXmlString    = function( xmlString )
  2064. {
  2065.     var xmlDoc    = null;
  2066.     
  2067.     if ( window.ActiveXObject )
  2068.     {
  2069.         xmlDoc = CMCXmlParser.GetMicrosoftXmlDomObject();
  2070.         xmlDoc.async = false;
  2071.         xmlDoc.loadXML( xmlString );
  2072.     }
  2073.     else if ( DOMParser )
  2074.     {
  2075.         var parser    = new DOMParser();
  2076.         
  2077.         xmlDoc = parser.parseFromString( xmlString, "text/xml" );
  2078.     }
  2079.     
  2080.     return xmlDoc;
  2081. }
  2082.  
  2083. CMCXmlParser.CreateXmlDocument    = function( rootTagName )
  2084. {
  2085.     var rootXml    = "<" + rootTagName + " />";
  2086.     var xmlDoc    = CMCXmlParser.LoadXmlString( rootXml );
  2087.     
  2088.     return xmlDoc;
  2089. }
  2090.  
  2091. CMCXmlParser.GetOuterXml    = function( xmlDoc )
  2092. {
  2093.     var xml    = null;
  2094.     
  2095.     if ( window.ActiveXObject )
  2096.     {
  2097.         xml = xmlDoc.xml;
  2098.     }
  2099.     else if ( window.XMLSerializer )
  2100.     {
  2101.         var serializer  = new XMLSerializer();
  2102.         
  2103.         xml = serializer.serializeToString( xmlDoc );
  2104.     }
  2105.     
  2106.     return xml;
  2107. }
  2108.  
  2109. CMCXmlParser.CallWebService    = function( webServiceUrl, async, onCompleteFunc, onCompleteArgs )
  2110. {
  2111.     var xmlParser    = new CMCXmlParser( onCompleteArgs, onCompleteFunc );
  2112.     var xmlDoc        = xmlParser.LoadRemote( webServiceUrl, async );
  2113.     
  2114.     return xmlDoc;
  2115. }
  2116.  
  2117. //
  2118. //    End class CMCXmlParser
  2119. //
  2120.  
  2121. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  2122.  
  2123. //
  2124. //    Class CMCFlareStylesheet
  2125. //
  2126.  
  2127. var CMCFlareStylesheet    = new function()
  2128. {
  2129.     // Private member variables
  2130.  
  2131.     var mInitialized            = false;
  2132.     var mXmlDoc                    = null;
  2133.     var mInitializedResources    = false;
  2134.     var mResourceMap            = null;
  2135.     
  2136.     // Private methods
  2137.     
  2138.     function Init()
  2139.     {
  2140.         mXmlDoc = FMCGetStylesheet();
  2141.         
  2142.         mInitialized = true;
  2143.     }
  2144.     
  2145.     function InitializeResources()
  2146.     {
  2147.         mInitializedResources = true;
  2148.         mResourceMap = new CMCDictionary();
  2149.  
  2150.         var resourcesInfos = mXmlDoc.getElementsByTagName( "ResourcesInfo" );
  2151.  
  2152.         if ( resourcesInfos.length > 0 )
  2153.         {
  2154.             var resources    = resourcesInfos[0].getElementsByTagName( "Resource" );
  2155.  
  2156.             for ( var i = 0; i < resources.length; i++ )
  2157.             {
  2158.                 var resource    = resources[i];
  2159.                 var properties    = new CMCDictionary();
  2160.                 var name        = resource.getAttribute( "Name" );
  2161.                 
  2162.                 if ( !name ) { continue; }
  2163.  
  2164.                 for ( var j = 0; j < resource.attributes.length; j++ )
  2165.                 {
  2166.                     var attribute    = resource.attributes[j];
  2167.                     
  2168.                     properties.Add( attribute.nodeName.toLowerCase(), attribute.nodeValue.toLowerCase() );
  2169.                 }
  2170.  
  2171.                 mResourceMap.Add( name, properties );
  2172.             }
  2173.         }
  2174.     }
  2175.     
  2176.     // Public methods
  2177.     
  2178.     this.LookupValue    = function( styleName, styleClassName, propertyName, defaultValue )
  2179.     {
  2180.         if ( !mInitialized )
  2181.         {
  2182.             Init();
  2183.             
  2184.             if ( mXmlDoc == null )
  2185.             {
  2186.                 return defaultValue;
  2187.             }
  2188.         }
  2189.         
  2190.         var value                = defaultValue;
  2191.         var styleNodes            = mXmlDoc.getElementsByTagName( "Style" );
  2192.         var styleNodesLength    = styleNodes.length;
  2193.         var styleNode            = null;
  2194.         
  2195.         for ( var i = 0; i < styleNodesLength; i++ )
  2196.         {
  2197.             if ( styleNodes[i].getAttribute( "Name" ) == styleName )
  2198.             {
  2199.                 styleNode = styleNodes[i];
  2200.                 break;
  2201.             }
  2202.         }
  2203.         
  2204.         if ( styleNode == null )
  2205.         {
  2206.             return value;
  2207.         }
  2208.         
  2209.         var styleClassNodes            = styleNode.getElementsByTagName( "StyleClass" );
  2210.         var styleClassNodesLength    = styleClassNodes.length;
  2211.         var styleClassNode            = null;
  2212.         
  2213.         for ( var i = 0; i < styleClassNodesLength; i++ )
  2214.         {
  2215.             if ( styleClassNodes[i].getAttribute( "Name" ) == styleClassName )
  2216.             {
  2217.                 styleClassNode = styleClassNodes[i];
  2218.                 break;
  2219.             }
  2220.         }
  2221.         
  2222.         if ( styleClassNode == null )
  2223.         {
  2224.             return value;
  2225.         }
  2226.         
  2227.         var propertyNodes        = styleClassNode.getElementsByTagName( "Property" );
  2228.         var propertyNodesLength    = propertyNodes.length;
  2229.         var propertyNode        = null;
  2230.         
  2231.         for ( var i = 0; i < propertyNodesLength; i++ )
  2232.         {
  2233.             if ( propertyNodes[i].getAttribute( "Name" ) == propertyName )
  2234.             {
  2235.                 propertyNode = propertyNodes[i];
  2236.                 break;
  2237.             }
  2238.         }
  2239.         
  2240.         if ( propertyNode == null )
  2241.         {
  2242.             return value;
  2243.         }
  2244.         
  2245.         value = propertyNode.firstChild.nodeValue;
  2246.         value = FMCTrim( value );
  2247.         
  2248.         return value;
  2249.     };
  2250.     
  2251.     this.GetResourceProperty    = function( name, property, defaultValue )
  2252.     {
  2253.         if ( !mInitialized )
  2254.         {
  2255.             Init();
  2256.             
  2257.             if ( mXmlDoc == null )
  2258.             {
  2259.                 return defaultValue;
  2260.             }
  2261.         }
  2262.         
  2263.         if ( !mInitializedResources )
  2264.         {
  2265.             InitializeResources();
  2266.         }
  2267.         
  2268.         var properties    = mResourceMap.GetItem( name );
  2269.  
  2270.         if ( !properties )
  2271.         {
  2272.             return defaultValue;
  2273.         }
  2274.  
  2275.         var propValue    = properties.GetItem( property.toLowerCase() );
  2276.  
  2277.         if ( !propValue )
  2278.         {
  2279.             return defaultValue;
  2280.         }
  2281.  
  2282.         return propValue;
  2283.     };
  2284.     
  2285.     this.SetImageFromStylesheet    = function( img, styleName, styleClassName, propertyName, defaultValue, defaultWidth, defaultHeight )
  2286.     {
  2287.         var value    = this.LookupValue( styleName, styleClassName, propertyName, null );
  2288.         var imgSrc    = null;
  2289.         
  2290.         if ( value == null )
  2291.         {
  2292.             value = defaultValue;
  2293.             imgSrc = value;
  2294.         }
  2295.         else
  2296.         {
  2297.             value = FMCStripCssUrl( value );
  2298.             value = decodeURIComponent( value );
  2299.             value = escape( value );
  2300.             imgSrc = FMCGetSkinFolderAbsolute() + value;
  2301.         }
  2302.         
  2303.         img.src = imgSrc;
  2304.         img.style.width = this.GetResourceProperty( value, "Width", defaultWidth ) + "px";
  2305.         img.style.height = this.GetResourceProperty( value, "Height", defaultHeight ) + "px";
  2306.     };
  2307. }
  2308.  
  2309. //
  2310. //    End class CMCFlareStylesheet
  2311. //
  2312.  
  2313. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  2314.  
  2315. //
  2316. //    String helpers
  2317. //
  2318.  
  2319. String.IsNullOrEmpty = function( str )
  2320. {
  2321.     if ( str == null )
  2322.     {
  2323.         return true;
  2324.     }
  2325.     
  2326.     if ( str.length == 0 )
  2327.     {
  2328.         return true;
  2329.     }
  2330.     
  2331.     return false;
  2332. }
  2333.  
  2334. String.prototype.StartsWith = function( str, caseSensitive )
  2335. {
  2336.     if ( str == null )
  2337.     {
  2338.         return false;
  2339.     }
  2340.     
  2341.     if ( this.length < str.length )
  2342.     {
  2343.         return false;
  2344.     }
  2345.     
  2346.     var value1    = this;
  2347.     var value2    = str;
  2348.     
  2349.     if ( !caseSensitive )
  2350.     {
  2351.         value1 = value1.toLowerCase();
  2352.         value2 = value2.toLowerCase();
  2353.     }
  2354.     
  2355.     if ( value1.substring( 0, value2.length ) == value2 )
  2356.     {
  2357.         return true;
  2358.     }
  2359.     else
  2360.     {
  2361.         return false;
  2362.     }
  2363. }
  2364.  
  2365. String.prototype.EndsWith = function( str, caseSensitive )
  2366. {
  2367.     if ( str == null )
  2368.     {
  2369.         return false;
  2370.     }
  2371.     
  2372.     if ( this.length < str.length )
  2373.     {
  2374.         return false;
  2375.     }
  2376.     
  2377.     var value1    = this;
  2378.     var value2    = str;
  2379.     
  2380.     if ( !caseSensitive )
  2381.     {
  2382.         value1 = value1.toLowerCase();
  2383.         value2 = value2.toLowerCase();
  2384.     }
  2385.     
  2386.     if ( value1.substring( value1.length - value2.length ) == value2 )
  2387.     {
  2388.         return true;
  2389.     }
  2390.     else
  2391.     {
  2392.         return false;
  2393.     }
  2394. }
  2395.  
  2396. String.prototype.Contains = function( str, caseSensitive )
  2397. {
  2398.     var value1    = this;
  2399.     var value2    = str;
  2400.     
  2401.     if ( !caseSensitive )
  2402.     {
  2403.         value1 = value1.toLowerCase();
  2404.         value2 = value2.toLowerCase();
  2405.     }
  2406.     
  2407.     return value1.indexOf( value2 ) != -1;
  2408. }
  2409.  
  2410. String.prototype.Equals = function( str, caseSensitive )
  2411. {
  2412.     var value1    = this;
  2413.     var value2    = str;
  2414.     
  2415.     if ( !caseSensitive )
  2416.     {
  2417.         value1 = value1.toLowerCase();
  2418.         value2 = value2.toLowerCase();
  2419.     }
  2420.     
  2421.     return value1 == value2;
  2422. }
  2423.  
  2424. String.prototype.CountOf = function( str, caseSensitive )
  2425. {
  2426.     var count    = 0;
  2427.     var value1    = this;
  2428.     var value2    = str;
  2429.     
  2430.     if ( !caseSensitive )
  2431.     {
  2432.         value1 = value1.toLowerCase();
  2433.         value2 = value2.toLowerCase();
  2434.     }
  2435.     
  2436.     var lastIndex    = -1;
  2437.     
  2438.     while ( true )
  2439.     {
  2440.         lastIndex = this.indexOf( str, lastIndex + 1 );
  2441.         
  2442.         if ( lastIndex == -1 )
  2443.         {
  2444.             break;
  2445.         }
  2446.         
  2447.         count++;
  2448.     }
  2449.     
  2450.     return count;
  2451. }
  2452.  
  2453. String.prototype.Insert = function( startIndex, value )
  2454. {
  2455.     var newStr = null;
  2456.     
  2457.     if ( startIndex >= 0 )
  2458.     {
  2459.         newStr = this.substring( 0, startIndex );
  2460.     }
  2461.     else
  2462.     {
  2463.         newStr = this;
  2464.     }
  2465.     
  2466.     newStr += value;
  2467.     
  2468.     if ( startIndex >= 0 )
  2469.     {
  2470.         newStr += this.substring( startIndex );
  2471.     }
  2472.     
  2473.     return newStr;
  2474. }
  2475.  
  2476. String.prototype.Trim = function()
  2477. {
  2478.     return this.TrimLeft().TrimRight();
  2479. }
  2480.  
  2481. String.prototype.TrimLeft = function()
  2482. {
  2483.     var i = 0;
  2484.  
  2485.     for ( i = 0; i < this.length && this.charAt( i ) == " "; i++ );
  2486.  
  2487.     return this.substring( i, this.length );
  2488. }
  2489.  
  2490. String.prototype.TrimRight = function()
  2491. {
  2492.     var i = 0;
  2493.  
  2494.     for ( i = this.length - 1; i >= 0 && this.charAt( i ) == " "; i-- );
  2495.  
  2496.     return this.substring( 0, i + 1 );
  2497. }
  2498.  
  2499. //
  2500. //    End String helpers
  2501. //
  2502.  
  2503. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  2504.  
  2505. //
  2506. //    Array helpers
  2507. //
  2508.  
  2509. Array.prototype.Contains = function( item )
  2510. {
  2511.     for ( var i = 0, length = this.length; i < length; i++ )
  2512.     {
  2513.         if ( this[i] == item )
  2514.         {
  2515.             return true;
  2516.         }
  2517.     }
  2518.     
  2519.     return false;
  2520. }
  2521.  
  2522. Array.prototype.Insert = function( item, index )
  2523. {
  2524.     if ( index < 0 || index > this.length )
  2525.     {
  2526.         throw "Index out of bounds.";
  2527.     }
  2528.     
  2529.     this.splice( index, 0, item );
  2530. }
  2531.  
  2532. Array.prototype.Remove = function( index )
  2533. {
  2534.     if ( index < 0 || index > this.length )
  2535.     {
  2536.         throw "Index out of bounds.";
  2537.     }
  2538.  
  2539.     this.splice( index, 1 );
  2540. }
  2541.  
  2542. Array.prototype.RemoveValue = function( value )
  2543. {
  2544.     for ( var i = this.length - 1; i >= 0; i-- )
  2545.     {
  2546.         if ( this[i] == value )
  2547.         {
  2548.             this.Remove( i );
  2549.         }
  2550.     }
  2551. }
  2552.  
  2553. //
  2554. //    End Array helpers
  2555. //
  2556.  
  2557. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  2558.  
  2559. //
  2560. //    Class CMCDictionary
  2561. //
  2562.  
  2563. function CMCDictionary()
  2564. {
  2565.     // Public properties
  2566.     
  2567.     this.mMap        = new Object();
  2568.     this.mOverflows    = new Array();
  2569.     this.mLength    = 0;
  2570. }
  2571.  
  2572. CMCDictionary.prototype.GetLength    = function( key )
  2573. {
  2574.     return this.mLength;
  2575. };
  2576.  
  2577. CMCDictionary.prototype.ForEach    = function( func )
  2578. {
  2579.     var map    = this.mMap;
  2580.     
  2581.     for ( var key in map )
  2582.     {
  2583.         var value    = map[key];
  2584.         
  2585.         if ( !func( key, value ) )
  2586.         {
  2587.             return;
  2588.         }
  2589.     }
  2590.     
  2591.     var overflows    = this.mOverflows;
  2592.     
  2593.     for ( var i = 0, length = overflows.length; i < length; i++ )
  2594.     {
  2595.         var item    = overflows[i];
  2596.         
  2597.         if ( !func( item.Key, item.Value ) )
  2598.         {
  2599.             return;
  2600.         }
  2601.     }
  2602. };
  2603.  
  2604. CMCDictionary.prototype.GetItem    = function( key )
  2605. {
  2606.     var item    = null;
  2607.     
  2608.     if ( typeof( this.mMap[key] ) == "function" )
  2609.     {
  2610.         var index    = this.GetItemOverflowIndex( key );
  2611.         
  2612.         if ( index >= 0 )
  2613.         {
  2614.             item = this.mOverflows[index].Value;
  2615.         }
  2616.     }
  2617.     else
  2618.     {
  2619.         item = this.mMap[key];
  2620.         
  2621.         if ( typeof( item ) == "undefined" )
  2622.         {
  2623.             item = null;
  2624.         }
  2625.     }
  2626.  
  2627.     return item;
  2628. };
  2629.  
  2630. CMCDictionary.prototype.GetItemOverflowIndex    = function( key )
  2631. {
  2632.     var overflows    = this.mOverflows;
  2633.     
  2634.     for ( var i = 0, length = overflows.length; i < length; i++ )
  2635.     {
  2636.         if ( overflows[i].Key == key )
  2637.         {
  2638.             return i;
  2639.         }
  2640.     }
  2641.     
  2642.     return -1;
  2643. }
  2644.  
  2645. CMCDictionary.prototype.Remove    = function( key )
  2646. {
  2647.     if ( typeof( this.mMap[key] ) == "function" )
  2648.     {
  2649.         var index    = this.GetItemOverflowIndex( key );
  2650.         
  2651.         if ( index >= 0 )
  2652.         {
  2653.             this.mOverflows.splice( index, 1 )
  2654.             
  2655.             this.mLength--;
  2656.         }
  2657.     }
  2658.     else
  2659.     {
  2660.         if ( this.mMap[key] != "undefined" )
  2661.         {
  2662.             delete( this.mMap[key] );
  2663.             
  2664.             this.mLength--;
  2665.         }
  2666.     }
  2667. };
  2668.  
  2669. CMCDictionary.prototype.Add    = function( key, value )
  2670. {
  2671.     if ( typeof( this.mMap[key] ) == "function" )
  2672.     {
  2673.         var item    = this.GetItem( key );
  2674.         
  2675.         if ( item != null )
  2676.         {
  2677.             this.Remove( key );
  2678.         }
  2679.         
  2680.         this.mOverflows[this.mOverflows.length] = { Key: key, Value: value };
  2681.     }
  2682.     else
  2683.     {
  2684.         this.mMap[key] = value;
  2685.     }
  2686.     
  2687.     this.mLength++;
  2688. };
  2689.  
  2690. CMCDictionary.prototype.AddUnique    = function( key, value )
  2691. {
  2692.     var savedValue    = this.GetItem( key );
  2693.     
  2694.     if ( typeof( savedValue ) == "undefined" || !savedValue )
  2695.     {
  2696.         this.Add( key, value );
  2697.     }
  2698. };
  2699.  
  2700. //
  2701. //    End class CMCDictionary
  2702. //
  2703.  
  2704. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  2705.  
  2706. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  2707.  
  2708. //
  2709. //    Class CMCUrl
  2710. //
  2711.  
  2712. function CMCUrl( src )
  2713. {
  2714.     // Private member variables
  2715.     
  2716.     var mSelf    = this;
  2717.     
  2718.     // Public properties
  2719.  
  2720.     this.FullPath            = null;
  2721.     this.Path                = null;
  2722.     this.PlainPath            = null;
  2723.     this.Name                = null;
  2724.     this.Extension            = null;
  2725.     this.NameWithExtension    = null;
  2726.     this.Fragment            = null;
  2727.     this.Query                = null;
  2728.     this.IsAbsolute            = false;
  2729.  
  2730.     // Constructor
  2731.  
  2732.     (function()
  2733.     {
  2734.         var fragment    = "";
  2735.         var query        = "";
  2736.         var fragmentPos    = src.indexOf( "#" );
  2737.         var queryPos    = src.indexOf( "?" );
  2738.         
  2739.         if ( fragmentPos != -1 )
  2740.         {
  2741.             if ( fragmentPos > queryPos )
  2742.             {
  2743.                 fragment = src.substring( fragmentPos );
  2744.             }
  2745.             else
  2746.             {
  2747.                 fragment = src.substring( fragmentPos, queryPos );
  2748.             }
  2749.         }
  2750.         
  2751.         if ( queryPos != -1 )
  2752.         {
  2753.             if ( queryPos > fragmentPos )
  2754.             {
  2755.                 query = src.substring( queryPos );
  2756.             }
  2757.             else
  2758.             {
  2759.                 query = src.substring( queryPos, fragmentPos );
  2760.             }
  2761.         }
  2762.         
  2763.         var pos            = Math.max( fragmentPos, queryPos );
  2764.         var plainPath    = src.substring( 0, pos == -1 ? src.length : pos );
  2765.         pos = plainPath.lastIndexOf( "/" );
  2766.         var path        = plainPath.substring( 0, pos + 1 );
  2767.         var nameWithExt    = plainPath.substring( pos + 1 );
  2768.         pos = nameWithExt.lastIndexOf( "." );
  2769.         var name        = nameWithExt.substring( 0, pos );
  2770.         var ext            = nameWithExt.substring( pos + 1 );
  2771.         
  2772.         var scheme        = "";
  2773.         pos = src.indexOf( ":" );
  2774.         
  2775.         if ( pos >= 0 )
  2776.         {
  2777.             scheme = src.substring( 0, pos );
  2778.         }
  2779.         
  2780.         mSelf.FullPath = src;
  2781.         mSelf.Path = path;
  2782.         mSelf.PlainPath = plainPath;
  2783.         mSelf.Name = name;
  2784.         mSelf.Extension = ext;
  2785.         mSelf.NameWithExtension = nameWithExt;
  2786.         mSelf.Scheme = scheme;
  2787.         mSelf.IsAbsolute = !String.IsNullOrEmpty( scheme );
  2788.         mSelf.Fragment = fragment;
  2789.         mSelf.Query = query;
  2790.     })();
  2791. }
  2792.  
  2793. // Public static properties
  2794.  
  2795. CMCUrl.QueryMap    = new CMCDictionary();
  2796. CMCUrl.HashMap    = new CMCDictionary();
  2797.  
  2798. (function()
  2799. {
  2800.     var search    = document.location.search;
  2801.     
  2802.     if ( !String.IsNullOrEmpty( search ) )
  2803.     {
  2804.         search = search.substring( 1 );
  2805.         Parse( search, "&", CMCUrl.QueryMap );
  2806.     }
  2807.     
  2808.     var hash    = document.location.hash;
  2809.     
  2810.     if ( !String.IsNullOrEmpty( hash ) )
  2811.     {
  2812.         hash = hash.substring( 1 );
  2813.         Parse( hash, "|", CMCUrl.HashMap );
  2814.     }
  2815.     
  2816.     function Parse( item, delimiter, map )
  2817.     {
  2818.         var split    = item.split( delimiter );
  2819.     
  2820.         for ( var i = 0, length = split.length; i < length; i++ )
  2821.         {
  2822.             var part    = split[i];
  2823.             var index    = part.indexOf( "=" );
  2824.             var key        = null;
  2825.             var value    = null;
  2826.             
  2827.             if ( index >= 0 )
  2828.             {
  2829.                 key = decodeURIComponent( part.substring( 0, index ) );
  2830.                 value = decodeURIComponent( part.substring( index + 1 ) );
  2831.             }
  2832.             else
  2833.             {
  2834.                 key = part;
  2835.             }
  2836.  
  2837.             map.Add( key, value );
  2838.         }
  2839.     }
  2840. })();
  2841.  
  2842. //
  2843.  
  2844. CMCUrl.prototype.AddFile    = function( otherUrl )
  2845. {
  2846.     if ( typeof( otherUrl ) == "string" )
  2847.     {
  2848.         otherUrl = new CMCUrl( otherUrl );
  2849.     }
  2850.     
  2851.     if ( otherUrl.IsAbsolute )
  2852.     {
  2853.         return otherUrl;
  2854.     }
  2855.     
  2856.     var otherFullPath = otherUrl.FullPath;
  2857.     
  2858.     if ( otherFullPath.charAt( 0 ) == "/" )
  2859.     {
  2860.         var loc            = document.location;
  2861.         var pos            = loc.href.lastIndexOf( loc.pathname );
  2862.         var rootPath    = loc.href.substring( 0, pos );
  2863.         
  2864.         return new CMCUrl( rootPath + otherFullPath );
  2865.     }
  2866.     
  2867.     var fullPath = this.FullPath;
  2868.     
  2869.     if ( !fullPath.EndsWith( "/" ) )
  2870.     {
  2871.         fullPath = fullPath + "/";
  2872.     }
  2873.     
  2874.     return new CMCUrl( fullPath + otherFullPath );
  2875. };
  2876.  
  2877. CMCUrl.prototype.CombinePath    = function( otherUrl )
  2878. {
  2879.     if ( typeof( otherUrl ) == "string" )
  2880.     {
  2881.         otherUrl = new CMCUrl( otherUrl );
  2882.     }
  2883.     
  2884.     if ( otherUrl.IsAbsolute )
  2885.     {
  2886.         throw new CMCException( -1, "Cannot combine two absolute paths." );
  2887.     }
  2888.     
  2889.     var otherFullPath = otherUrl.FullPath;
  2890.     var fullPath = this.FullPath;
  2891.     var segments = otherUrl.FullPath.split( "/" );
  2892.     
  2893.     var curr = this.FullPath;
  2894.     var prefix = "";
  2895.     
  2896.     if ( this.Scheme == "mk" )
  2897.     {
  2898.         var pos = curr.indexOf( "::" );
  2899.         prefix = curr.substring( 0, pos + "::".length );
  2900.         curr = curr.substring( pos + "::".length );
  2901.     }
  2902.     
  2903.     for ( var i = 0, length = segments.length; i < length; i++ )
  2904.     {
  2905.         var seg = segments[i];
  2906.         
  2907.         if ( String.IsNullOrEmpty( seg ) )
  2908.         {
  2909.             continue;
  2910.         }
  2911.         
  2912.         if ( curr.length > 1 && curr.EndsWith( "/" ) )
  2913.         {
  2914.             curr = curr.substring( 0, curr.length - 1 );
  2915.         }
  2916.         
  2917.         if ( seg == "." )
  2918.         {
  2919.             curr += "/";
  2920.         }
  2921.         else if ( seg == ".." )
  2922.         {
  2923.             curr = curr.substring( 0, curr.lastIndexOf( "/" ) + 1 );
  2924.         }
  2925.         else
  2926.         {
  2927.             if ( !curr.EndsWith( "/" ) )
  2928.             {
  2929.                 curr += "/";
  2930.             }
  2931.             
  2932.             curr += seg;
  2933.         }
  2934.     }
  2935.     
  2936.     curr = prefix + curr;
  2937.     
  2938.     return new CMCUrl( curr );
  2939. };
  2940.  
  2941. CMCUrl.prototype.ToQuery = function(query)
  2942. {
  2943.     var newPath = this.PlainPath + "?" + query + this.Fragment;
  2944.  
  2945.     return new CMCUrl(newPath);
  2946. };
  2947.  
  2948. CMCUrl.prototype.ToFolder    = function()
  2949. {
  2950.     var fullPath = this.PlainPath;
  2951.     var pos = fullPath.lastIndexOf( "/" );
  2952.     var newPath = fullPath.substring( 0, pos + 1 );
  2953.  
  2954.     return new CMCUrl( newPath );
  2955. };
  2956.  
  2957. CMCUrl.prototype.ToRelative    = function( otherUrl )
  2958. {
  2959.     var path        = otherUrl.FullPath;
  2960.     var otherPath    = this.FullPath;
  2961.     var pos            = otherPath.indexOf( path );
  2962.     var relPath        = null;
  2963.     
  2964.     if ( pos == 0 )
  2965.     {
  2966.         relPath = otherPath.substring( path.length );
  2967.     }
  2968.     else
  2969.     {
  2970.         relPath = otherPath;
  2971.     }
  2972.     
  2973.     return new CMCUrl( relPath );
  2974. };
  2975.  
  2976. CMCUrl.prototype.ToExtension    = function( newExt )
  2977. {
  2978.     var path    = this.FullPath;
  2979.     var pos        = path.lastIndexOf( "." );
  2980.     var left    = path.substring( 0, pos );
  2981.     var newPath    = left + "." + newExt;
  2982.     
  2983.     return new CMCUrl( newPath );
  2984. };
  2985.  
  2986. //
  2987. //    End class CMCUrl
  2988. //
  2989.  
  2990. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  2991.  
  2992. //
  2993. //    DOM traversal functions
  2994. //
  2995.  
  2996. function FMCGetElementsByClassRoot( node, classRoot )
  2997. {
  2998.     var nodes   = new Array();
  2999.     var args    = new Array();
  3000.     
  3001.     args[0] = nodes;
  3002.     args[1] = classRoot;
  3003.     
  3004.     FMCTraverseDOM( "post", node, FMCGetByClassRoot, args );
  3005.                          
  3006.     return nodes;
  3007. }
  3008.  
  3009. function FMCGetByClassRoot( node, args )
  3010. {
  3011.     var nodes       = args[0];
  3012.     var classRoot   = args[1];
  3013.     
  3014.     if ( node.nodeType == 1 && FMCContainsClassRoot( node.className, classRoot ) )
  3015.     {
  3016.         nodes[nodes.length] = node;
  3017.     }
  3018. }
  3019.  
  3020. function FMCGetElementsByAttribute( node, attribute, value )
  3021. {
  3022.     var nodes   = new Array();
  3023.     var args    = new Array();
  3024.     
  3025.     args[0] = nodes;
  3026.     args[1] = attribute;
  3027.     args[2] = value;
  3028.     
  3029.     FMCTraverseDOM( "post", node, FMCGetByAttribute, args );
  3030.                          
  3031.     return nodes;
  3032. }
  3033.  
  3034. function FMCGetByAttribute( node, args )
  3035. {
  3036.     var nodes       = args[0];
  3037.     var attribute   = args[1];
  3038.     var value       = args[2];
  3039.     
  3040.     try
  3041.     {
  3042.         if ( node.nodeType == 1 && (FMCGetMCAttribute( node, attribute ) == value || (value == "*" && FMCGetMCAttribute( node, attribute ))) )
  3043.         {
  3044.             nodes[nodes.length] = node;
  3045.         }
  3046.     }
  3047.     catch( err )
  3048.     {
  3049.         node.setAttribute( attribute, null );
  3050.     }
  3051. }
  3052.  
  3053. function FMCTraverseDOM( type, root, Func, args )
  3054. {
  3055.     if ( type == "pre" )
  3056.     {
  3057.         Func( root, args );
  3058.     }
  3059.     
  3060.     if ( root.childNodes.length != 0 )
  3061.     {
  3062.         for ( var i = 0; i < root.childNodes.length; i++ )
  3063.         {
  3064.             FMCTraverseDOM( type, root.childNodes[i], Func, args );
  3065.         }
  3066.     }
  3067.     
  3068.     if ( type == "post" )
  3069.     {
  3070.         Func( root, args );
  3071.     }
  3072. }
  3073.  
  3074. //
  3075. //    End DOM traversal functions
  3076. //
  3077.  
  3078. //
  3079. //    Button effects
  3080. //
  3081.  
  3082. var gButton        = null;
  3083. var gTabIndex    = 1;
  3084.  
  3085. function MakeButton( td, title, outImagePath, overImagePath, selectedImagePath, width, height, text )
  3086. {
  3087.     var div    = document.createElement( "div" );
  3088.     
  3089.     div.tabIndex = gTabIndex++;
  3090.     
  3091.     title ? div.title = title : false;
  3092.     div.setAttribute( "MadCap:outImage", outImagePath );
  3093.     div.setAttribute( "MadCap:overImage", overImagePath );
  3094.     div.setAttribute( "MadCap:selectedImage", selectedImagePath );
  3095.     div.setAttribute( "MadCap:width", width );
  3096.     div.setAttribute( "MadCap:height", height );
  3097.     
  3098.     FMCPreloadImage( outImagePath );
  3099.     FMCPreloadImage( overImagePath );
  3100.     FMCPreloadImage( selectedImagePath );
  3101.     
  3102.     div.appendChild( document.createTextNode( text ) );
  3103.     td.appendChild( div );
  3104.     
  3105.     InitButton( div );
  3106. }
  3107.  
  3108. function InitButton( button )
  3109. {
  3110.     var width    = parseInt( FMCGetMCAttribute( button, "MadCap:width" ) ) + "px";
  3111.     var height    = parseInt( FMCGetMCAttribute( button, "MadCap:height" ) ) + "px";
  3112.     var image    = FMCGetMCAttribute( button, "MadCap:outImage" );
  3113.     
  3114.     if ( image != null )
  3115.     {
  3116.         if ( !image.StartsWith( "url", false ) || !image.EndsWith( ")", false ) )
  3117.         {
  3118.             image = FMCCreateCssUrl( image );
  3119.         }
  3120.  
  3121.         button.style.backgroundImage = image;
  3122.         
  3123.         button.onmouseover = ButtonOnOver;
  3124.         button.onmouseout = ButtonOnOut;
  3125.         button.onmousedown = ButtonOnDown;
  3126.     }
  3127.     
  3128.     button.style.cursor = "default";
  3129.     button.style.width = width;
  3130.     button.style.height = height;
  3131.  
  3132.     button.parentNode.style.width = width;
  3133.     button.parentNode.style.height = height;
  3134. }
  3135.  
  3136. function ButtonOnOver()
  3137. {
  3138.     var image    = FMCGetMCAttribute( this, "MadCap:overImage" );
  3139.     
  3140.     if ( !image.StartsWith( "url", false ) || !image.EndsWith( ")", false ) )
  3141.     {
  3142.         image = FMCCreateCssUrl( image );
  3143.     }
  3144.     
  3145.     this.style.backgroundImage = image;
  3146. }
  3147.  
  3148. function ButtonOnOut()
  3149. {
  3150.     var image    = FMCGetMCAttribute( this, "MadCap:outImage" );
  3151.     
  3152.     if ( !image.StartsWith( "url", false ) || !image.EndsWith( ")", false ) )
  3153.     {
  3154.         image = FMCCreateCssUrl( image );
  3155.     }
  3156.     
  3157.     this.style.backgroundImage = image;
  3158. }
  3159.  
  3160. function ButtonOnDown()
  3161. {
  3162.     StartPress( this ); return false;
  3163. }
  3164.  
  3165. function StartPress( node )
  3166. {
  3167.     // Debug
  3168.     //window.status += "s";
  3169.     
  3170.     gButton = node;
  3171.     
  3172.     if ( document.body.setCapture )
  3173.     {
  3174.         document.body.setCapture();
  3175.         
  3176.         document.body.onmousemove = Press;
  3177.         document.body.onmouseup = EndPress;
  3178.     }
  3179.     else if ( document.addEventListener )
  3180.     {
  3181.         document.addEventListener( "mousemove", Press, true );
  3182.         document.addEventListener( "mouseup", EndPress, true );
  3183.     }
  3184.     
  3185.     gButton.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( gButton, "MadCap:selectedImage" ) );
  3186.     gButton.onmouseover = function() { this.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( this, "MadCap:selectedImage" ) ); };
  3187. }
  3188.  
  3189. function Press( e )
  3190. {
  3191.     // Debug
  3192.     //window.status += "p";
  3193.     
  3194.     if ( !e )
  3195.     {
  3196.         e = window.event;
  3197.         target = e.srcElement;
  3198.     }
  3199.     else if ( e.target )
  3200.     {
  3201.         target = e.target;
  3202.     }
  3203.     
  3204.     if ( target == gButton )
  3205.     {
  3206.         gButton.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( gButton, "MadCap:selectedImage" ) );
  3207.     }
  3208.     else
  3209.     {
  3210.         gButton.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( gButton, "MadCap:outImage" ) );
  3211.     }
  3212. }
  3213.  
  3214. function EndPress( e )
  3215. {
  3216.     // Debug
  3217.     //window.status += "e";
  3218.     
  3219.     var target  = null;
  3220.     
  3221.     if ( !e )
  3222.     {
  3223.         e = window.event;
  3224.         target = e.srcElement;
  3225.     }
  3226.     else if ( e.target )
  3227.     {
  3228.         target = e.target;
  3229.     }
  3230.     
  3231.     if ( target == gButton )
  3232.     {
  3233.         // Debug
  3234.         //window.status += "c";
  3235.         
  3236.         gButton.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( gButton, "MadCap:overImage" ) );
  3237.     }
  3238.     
  3239.     gButton.onmouseover = function() { this.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( this, "MadCap:overImage" ) ); };
  3240.     
  3241.     if ( document.body.releaseCapture )
  3242.     {
  3243.         document.body.releaseCapture();
  3244.         
  3245.         document.body.onmousemove = null;
  3246.         document.body.onmouseup = null;
  3247.     }
  3248.     else if ( document.removeEventListener )
  3249.     {
  3250.         document.removeEventListener( "mousemove", Press, true );
  3251.         document.removeEventListener( "mouseup", EndPress, true );
  3252.     }
  3253.     
  3254.     gButton = null;
  3255. }
  3256.  
  3257. //
  3258. //    End button effects
  3259. //
  3260.  
  3261. if ( FMCIsWebHelpAIR() )
  3262. {
  3263.     gOnloadFuncs.splice( 0, 0, FMCInitializeBridge );
  3264.  
  3265.     function FMCInitializeBridge()
  3266.     {
  3267.         if ( window.parentSandboxBridge )
  3268.         {
  3269.             if ( typeof( gServiceClient ) != "undefined" )
  3270.             {
  3271.                 gServiceClient = {};
  3272.             }
  3273.             
  3274.             for ( var key in window.parentSandboxBridge )
  3275.             {
  3276.                 var pairs        = key.split( "_" );
  3277.                 var ns            = pairs[0];
  3278.                 var funcName    = pairs[1];
  3279.                 
  3280.                 if ( ns == "FeedbackServiceClient" )
  3281.                 {
  3282.                     if ( typeof( gServiceClient ) != "undefined" )
  3283.                     {
  3284.                         gServiceClient[funcName] = window.parentSandboxBridge[key];
  3285.                     }
  3286.                 }
  3287.                 else if ( ns == "MadCapUtilities" )
  3288.                 {
  3289.                     window[funcName] = window.parentSandboxBridge[key];
  3290.                 }
  3291.             }
  3292.         }
  3293.     }
  3294. }
  3295.  
  3296. var MCFader    = new function()
  3297. {
  3298.     // Public methods
  3299.  
  3300.     this.FadeIn    = function( node, startOpacity, endOpacity, nodeBG, startOpacityBG, endOpacityBG, handleClick )
  3301.     {
  3302.         var interval    = 0;
  3303.  
  3304.         FMCSetOpacity( node, startOpacity );
  3305.         
  3306.         if ( nodeBG != null )
  3307.         {
  3308.             FMCSetOpacity( nodeBG, startOpacityBG );
  3309.         }
  3310.  
  3311.         function DoFadeIn()
  3312.         {
  3313.             if ( !FMCIsInDom( node ) )    // Node was already removed from the DOM.
  3314.             {
  3315.                 clearInterval( interval );
  3316.                 
  3317.                 return;
  3318.             }
  3319.             
  3320.             var opacity    = FMCGetOpacity( node );
  3321.             
  3322.             if ( opacity == startOpacity || opacity == -1 )
  3323.             {
  3324.                 if ( handleClick )
  3325.                 {
  3326.                     var funcIndex    = -1;
  3327.                     
  3328.                     function OnClickDocument()
  3329.                     {
  3330.                         node.parentNode.removeChild( node );
  3331.                         
  3332.                         if ( nodeBG != null )
  3333.                         {
  3334.                             nodeBG.parentNode.removeChild( nodeBG );
  3335.                         }
  3336.                         
  3337.                         gDocumentOnclickFuncs.splice( funcIndex, 1 );
  3338.                     }
  3339.                     
  3340.                     funcIndex = gDocumentOnclickFuncs.push( OnClickDocument ) - 1;
  3341.                 }
  3342.             }
  3343.             
  3344.             if ( opacity == -1 )
  3345.             {
  3346.                 clearInterval( interval );
  3347.                 
  3348.                 return;
  3349.             }
  3350.             
  3351.             var opacityStep = (endOpacity - startOpacity) / 10;
  3352.             var newOpacity = opacity + opacityStep;
  3353.             FMCSetOpacity( node, newOpacity );
  3354.  
  3355.             if ( newOpacity >= endOpacity )
  3356.             {
  3357.                 clearInterval( interval );
  3358.                 
  3359.                 if ( nodeBG != null )
  3360.                 {
  3361.                     FMCSetOpacity( nodeBG, endOpacityBG );
  3362.                 }
  3363.             }
  3364.         }
  3365.  
  3366.         interval = setInterval( DoFadeIn, 10 );
  3367.     };
  3368. }
  3369.  
  3370. //
  3371. //    Class CMCDateTimeHelpers
  3372. //
  3373.  
  3374. var CMCDateTimeHelpers = new function()
  3375. {
  3376.     this.GetDateFromUTCString = function( utcString )
  3377.     {
  3378.         var ms        = Date.parse( utcString );
  3379.         var date    = new Date( ms );
  3380.         var utcMS    = Date.UTC( date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds() );
  3381.         var utcDate    = new Date( utcMS );
  3382.         
  3383.         return utcDate;
  3384.     };
  3385.     
  3386.     this.ToUIString = function( date )
  3387.     {
  3388.         var dateStr = (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.toLocaleTimeString();
  3389.  
  3390.         return dateStr;
  3391.     };
  3392. }
  3393.  
  3394. //
  3395. //    End class CMCDateTimeHelpers
  3396. //
  3397.  
  3398. //
  3399. //    Class CMCException
  3400. //
  3401.  
  3402. function CMCException( number, message )
  3403. {
  3404.     // Private member variables and functions
  3405.  
  3406.     this.Number        = number;
  3407.     this.Message    = message;
  3408. }
  3409.  
  3410. //
  3411. //    End class CMCException
  3412. //
  3413.  
  3414. var MCGlobals    = new function()
  3415. {
  3416.     // Private member variables
  3417.     
  3418.     var mSelf    = this;
  3419.     
  3420.     // Public properties
  3421.  
  3422.     var inPreviewMode = FMCGetAttributeBool( document.documentElement, "MadCap:InPreviewMode", false );
  3423.     
  3424.     if ( inPreviewMode )
  3425.     {
  3426.         this.InPreviewMode = true;
  3427.         
  3428.         this.SkinFolder = "Skin/";
  3429.         this.SkinTemplateFolder = "SkinTemplate/";
  3430.     }
  3431.     else
  3432.     {
  3433.         var masterHS = FMCGetHelpSystem();
  3434.         
  3435.         this.SubsystemFile        = FMCGetAttribute( document.documentElement, "MadCap:HelpSystemFileName" );
  3436.         this.SkinFolder            = masterHS.SkinFolder;
  3437.         this.SkinTemplateFolder    = masterHS.SkinTemplateFolder;
  3438.         this.DefaultStartTopic    = masterHS.DefaultStartTopic;
  3439.         this.InPreviewMode      = masterHS.InPreviewMode;
  3440.     }
  3441.     
  3442.     this.Initialized        = false;
  3443.     
  3444.     this.RootFolder                = null;
  3445.     this.RootFrame                = null;
  3446.     this.ToolbarFrame            = null;
  3447.     this.BodyFrame                = null;
  3448.     this.NavigationFrame        = null;
  3449.     this.BodyCommentsFrame        = null;
  3450.     this.PersistenceFrame        = null;
  3451.     
  3452.     // Private methods
  3453.     
  3454.     function InitRoot()
  3455.     {
  3456.         mSelf.RootFrame = window;
  3457.         mSelf.ToolbarFrame = frames["mctoolbar"];
  3458.         mSelf.BodyFrame = frames["body"];
  3459.         mSelf.NavigationFrame = frames["navigation"];
  3460.         mSelf.PersistenceFrame = null;
  3461.         
  3462.         //
  3463.  
  3464.         FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  3465.             
  3466.         function OnBodyReady( args )
  3467.         {
  3468.             mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  3469.  
  3470.             //
  3471.  
  3472.             mSelf.Initialized = true;
  3473.         }
  3474.     }
  3475.     
  3476.     function InitTopicCHM()
  3477.     {
  3478.         mSelf.RootFrame = null;
  3479.         mSelf.ToolbarFrame = frames["mctoolbar"];
  3480.         mSelf.BodyFrame = window;
  3481.         mSelf.NavigationFrame = null;
  3482.         mSelf.BodyCommentsFrame = frames["topiccomments"];
  3483.         mSelf.PersistenceFrame = frames["persistence"];
  3484.         
  3485.         //
  3486.             
  3487.         mSelf.Initialized = true;
  3488.     }
  3489.     
  3490.     function InitNavigation()
  3491.     {
  3492.         mSelf.RootFrame = parent;
  3493.         mSelf.NavigationFrame = window;
  3494.         mSelf.PersistenceFrame = null;
  3495.         
  3496.         FMCRegisterCallback( "Root", MCEventType.OnReady, OnRootReady, null );
  3497.             
  3498.         function OnRootReady( args )
  3499.         {
  3500.             mSelf.ToolbarFrame = mSelf.RootFrame.frames["mctoolbar"];
  3501.             mSelf.BodyFrame = mSelf.RootFrame.frames["body"];
  3502.             
  3503.             var bodyReady    = false;
  3504.             var rootLoaded    = false;
  3505.             
  3506.             FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  3507.             
  3508.             function OnBodyReady( args )
  3509.             {
  3510.                 bodyReady = true;
  3511.                 
  3512.                 mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  3513.                 
  3514.                 //
  3515.                 
  3516.                 if ( FMCIsWebHelpAIR() )
  3517.                 {
  3518.                     if ( rootLoaded )
  3519.                     {
  3520.                         mSelf.Initialized = true;
  3521.                     }
  3522.                 }
  3523.                 else
  3524.                 {
  3525.                     mSelf.Initialized = true;
  3526.                 }
  3527.             }
  3528.             
  3529.             if ( FMCIsWebHelpAIR() )
  3530.             {
  3531.                 FMCRegisterCallback( "Root", MCEventType.OnLoad, OnRootLoaded, null );
  3532.                 
  3533.                 function OnRootLoaded( args )
  3534.                 {
  3535.                     rootLoaded = true;
  3536.                     
  3537.                     if ( bodyReady )
  3538.                     {
  3539.                         mSelf.Initialized = true;
  3540.                     }
  3541.                 }
  3542.             }
  3543.         }
  3544.     }
  3545.     
  3546.     function InitNavigationFramesWebHelp()
  3547.     {
  3548.         var bodyReady    = false;
  3549.         
  3550.         mSelf.RootFrame = parent.parent;
  3551.         mSelf.NavigationFrame = parent;
  3552.         mSelf.PersistenceFrame = null;
  3553.         
  3554.         FMCRegisterCallback( "Root", MCEventType.OnReady, OnRootReady, null );
  3555.             
  3556.         function OnRootReady( args )
  3557.         {
  3558.             mSelf.ToolbarFrame = mSelf.RootFrame.frames["mctoolbar"];
  3559.             mSelf.BodyFrame = mSelf.RootFrame.frames["body"];
  3560.             
  3561.             FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  3562.             
  3563.             function OnBodyReady( args )
  3564.             {
  3565.                 mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  3566.                 
  3567.                 //
  3568.                 
  3569.                 bodyReady = true;
  3570.                 
  3571.                 if ( window.name == "search" && FMCIsWebHelpAIR() )
  3572.                 {
  3573.                     if ( window.parentSandboxBridge != null )
  3574.                     {
  3575.                         mSelf.Initialized = true;
  3576.                     }
  3577.                 }
  3578.                 else
  3579.                 {
  3580.                     mSelf.Initialized = true;
  3581.                 }
  3582.             }
  3583.         }
  3584.         
  3585.         FMCRegisterCallback( "Navigation", MCEventType.OnReady, OnNavigationReady, null );
  3586.             
  3587.         function OnNavigationReady( args )
  3588.         {
  3589.             if ( window.name == "search" && FMCIsWebHelpAIR() )
  3590.             {
  3591.                 FMCRegisterCallback( "Navigation", MCEventType.OnLoad, OnNavigationLoaded, null );
  3592.                 
  3593.                 function OnNavigationLoaded( args )
  3594.                 {
  3595.                     if ( bodyReady )
  3596.                     {
  3597.                         mSelf.Initialized = true;
  3598.                     }
  3599.                 }
  3600.             }
  3601.             else
  3602.             {
  3603.                 if ( bodyReady )
  3604.                 {
  3605.                     mSelf.Initialized = true;
  3606.                 }
  3607.             }
  3608.         }
  3609.     }
  3610.     
  3611.     function InitBodyCommentsFrameWebHelp()
  3612.     {
  3613.         var rootFrame = null;
  3614.         
  3615.         if ( parent.parent.gRuntimeFileType == "Default" )    // Standalone topic
  3616.         {
  3617.             rootFrame = parent.parent;
  3618.         }
  3619.         
  3620.         mSelf.RootFrame = rootFrame;
  3621.         mSelf.NavigationFrame = parent.parent.frames["navigation"];
  3622.         mSelf.PersistenceFrame = null;
  3623.         mSelf.ToolbarFrame = parent.parent.frames["mctoolbar"];
  3624.         mSelf.BodyFrame = parent;
  3625.         mSelf.BodyCommentsFrame = window;
  3626.  
  3627.         mSelf.Initialized = true;
  3628.     }
  3629.     
  3630.     function InitBodyCommentsFrameDotNetHelp()
  3631.     {
  3632.         mSelf.RootFrame = null;
  3633.         mSelf.ToolbarFrame = null;
  3634.         mSelf.BodyFrame = parent;
  3635.         mSelf.NavigationFrame = null;
  3636.         mSelf.BodyCommentsFrame = window;
  3637.         mSelf.PersistenceFrame = null;
  3638.  
  3639.         //
  3640.  
  3641.         mSelf.Initialized = true;
  3642.     }
  3643.     
  3644.     function InitToolbarWebHelp()
  3645.     {
  3646.         mSelf.RootFrame = parent;
  3647.         mSelf.ToolbarFrame = window;
  3648.         mSelf.PersistenceFrame = null;
  3649.         
  3650.         FMCRegisterCallback( "Root", MCEventType.OnReady, OnRootReady, null );
  3651.             
  3652.         function OnRootReady( args )
  3653.         {
  3654.             mSelf.BodyFrame = mSelf.RootFrame.frames["body"];
  3655.             mSelf.NavigationFrame = mSelf.RootFrame.frames["navigation"];
  3656.             
  3657.             //
  3658.             
  3659.             FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  3660.             
  3661.             function OnBodyReady( args )
  3662.             {
  3663.                 mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  3664.  
  3665.                 //
  3666.  
  3667.                 mSelf.Initialized = true;
  3668.             }
  3669.         }
  3670.     }
  3671.     
  3672.     function InitToolbarWebHelpTopic()
  3673.     {
  3674.         mSelf.RootFrame = parent.parent;
  3675.         mSelf.PersistenceFrame = null;
  3676.         mSelf.BodyFrame = parent;
  3677.         
  3678.         FMCRegisterCallback( "Root", MCEventType.OnReady, OnRootReady, null );
  3679.             
  3680.         function OnRootReady( args )
  3681.         {
  3682.             mSelf.ToolbarFrame = mSelf.RootFrame.frames["mctoolbar"];
  3683.             mSelf.NavigationFrame = mSelf.RootFrame.frames["navigation"];
  3684.             
  3685.             //
  3686.             
  3687.             FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  3688.             
  3689.             function OnBodyReady( args )
  3690.             {
  3691.                 mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  3692.                 
  3693.                 //
  3694.  
  3695.                 mSelf.Initialized = true;
  3696.             }
  3697.         }
  3698.     }
  3699.     
  3700.     function InitToolbarCHM()
  3701.     {
  3702.         mSelf.RootFrame = null;
  3703.         mSelf.ToolbarFrame = window;
  3704.         mSelf.BodyFrame = parent;
  3705.         mSelf.NavigationFrame = null;
  3706.         
  3707.         FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  3708.             
  3709.         function OnBodyReady( args )
  3710.         {
  3711.             mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  3712.             mSelf.PersistenceFrame = mSelf.BodyFrame.frames["persistence"];
  3713.             
  3714.             //
  3715.         
  3716.             mSelf.Initialized = true;
  3717.         }
  3718.     }
  3719.     
  3720.     function InitTopicWebHelp()
  3721.     {
  3722.         var rootFrame = null;
  3723.         
  3724.         if ( parent.gRuntimeFileType == "Default" )    // Standalone topic
  3725.         {
  3726.             rootFrame = parent;
  3727.         }
  3728.         
  3729.         mSelf.RootFrame = rootFrame;
  3730.         mSelf.BodyFrame = window;
  3731.         mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  3732.         mSelf.PersistenceFrame = null;
  3733.         
  3734.         if ( mSelf.RootFrame == null )    // Standalone topic
  3735.         {
  3736.             mSelf.Initialized = true;
  3737.         }
  3738.         else
  3739.         {
  3740.             function OnRootReady( args )
  3741.             {
  3742.                 mSelf.ToolbarFrame = mSelf.RootFrame.frames["mctoolbar"];
  3743.                 mSelf.NavigationFrame = mSelf.RootFrame.frames["navigation"];
  3744.                 
  3745.                 if ( FMCIsWebHelpAIR() )
  3746.                 {
  3747.                     FMCRegisterCallback( "Root", MCEventType.OnLoad, OnRootLoaded, null );
  3748.                     
  3749.                     function OnRootLoaded( args )
  3750.                     {
  3751.                         mSelf.Initialized = true;
  3752.                     }
  3753.                 }
  3754.                 else
  3755.                 {
  3756.                     mSelf.Initialized = true;
  3757.                 }
  3758.             }
  3759.             
  3760.             FMCRegisterCallback( "Root", MCEventType.OnReady, OnRootReady, null );
  3761.         }
  3762.     }
  3763.     
  3764.     function InitTopicDotNetHelp()
  3765.     {
  3766.         mSelf.RootFrame = null;
  3767.         mSelf.ToolbarFrame = null;
  3768.         mSelf.BodyFrame = window;
  3769.         mSelf.NavigationFrame = null;
  3770.         mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  3771.         mSelf.PersistenceFrame = null;
  3772.  
  3773.         //
  3774.  
  3775.         mSelf.Initialized = true;
  3776.     }
  3777.     
  3778.     function InitGlossaryFrameDotNetHelp()
  3779.     {
  3780.         mSelf.RootFrame = null;
  3781.         mSelf.ToolbarFrame = null;
  3782.         mSelf.BodyFrame = null;
  3783.         mSelf.NavigationFrame = null;
  3784.         mSelf.BodyCommentsFrame = null;
  3785.         mSelf.PersistenceFrame = null;
  3786.  
  3787.         //
  3788.  
  3789.         mSelf.Initialized = true;
  3790.     }
  3791.     
  3792.     function InitNavigationFramesCHM()
  3793.     {
  3794.         mSelf.RootFrame = null;
  3795.         mSelf.BodyFrame = parent;
  3796.         mSelf.NavigationFrame = null;
  3797.         
  3798.         FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  3799.             
  3800.         function OnBodyReady( args )
  3801.         {
  3802.             mSelf.ToolbarFrame = mSelf.BodyFrame.frames["mctoolbar"];
  3803.             mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  3804.             mSelf.PersistenceFrame = mSelf.BodyFrame.frames["persistence"];
  3805.             
  3806.             //
  3807.         
  3808.             mSelf.Initialized = true;
  3809.         }
  3810.     }
  3811.     
  3812.     // Public methods
  3813.     
  3814.     this.Init    = function()
  3815.     {
  3816.         if ( inPreviewMode )
  3817.         {
  3818.             mSelf.Initialized = true;
  3819.             
  3820.             return;
  3821.         }
  3822.         
  3823.         if ( window.name == "bridge" )
  3824.         {
  3825.             mSelf.Initialized = true;
  3826.             
  3827.             return;
  3828.         }
  3829.         else if ( gRuntimeFileType == "Default" || (gRuntimeFileType == "Topic" && FMCIsHtmlHelp()) )    // Root or topic in CHM
  3830.         {
  3831.             mSelf.ToolbarFrame = frames["mctoolbar"];
  3832.             
  3833.             if ( frames["body"] != null )    // Root
  3834.             {
  3835.                 InitRoot();
  3836.             }
  3837.             else                            // Topic in CHM
  3838.             {
  3839.                 InitTopicCHM();
  3840.             }
  3841.         }
  3842.         else if ( window.name == "navigation" )    // Navigation
  3843.         {
  3844.             InitNavigation();
  3845.         }
  3846.         else if ( parent.name == "navigation" )    // Navigation frames in WebHelp
  3847.         {
  3848.             InitNavigationFramesWebHelp();
  3849.         }
  3850.         else if ( window.name.StartsWith( "mctoolbar" ) )    // Toolbar
  3851.         {
  3852.             mSelf.ToolbarFrame = window;
  3853.             
  3854.             if ( parent.frames["navigation"] != null )    // Toolbar in WebHelp
  3855.             {
  3856.                 InitToolbarWebHelp();
  3857.             }
  3858.             else if ( FMCIsWebHelp() )    // Toolbar in WebHelp topic
  3859.             {
  3860.                 InitToolbarWebHelpTopic();
  3861.             }
  3862.             else                                        // Toolbar in CHM
  3863.             {
  3864.                 InitToolbarCHM();
  3865.             }
  3866.         }
  3867.         else if ( window.name == "body" || gRuntimeFileType == "Topic" )    // Topic in WebHelp - window.name is "body" when viewed in frameset, but gRuntimeFileType might not be "Topic" if it's an external topic. gRuntimeFileType is "Topic" when viewed as standalone, but window.name won't be "body".
  3868.         {
  3869.             if ( FMCIsWebHelp() )
  3870.             {
  3871.                 InitTopicWebHelp();
  3872.             }
  3873.             else if ( FMCIsDotNetHelp() )
  3874.             {
  3875.                 InitTopicDotNetHelp();
  3876.             }
  3877.             else if ( FMCIsHtmlHelp() )
  3878.             {
  3879.                 InitTopicCHM();
  3880.             }
  3881.         }
  3882.         else if ( window.name == "topiccomments" )
  3883.         {
  3884.             if ( parent.gRuntimeFileType != "Topic" )
  3885.             {
  3886.                 mSelf.Initialized = true;
  3887.                 
  3888.                 return;
  3889.             }
  3890.             
  3891.             if ( FMCIsHtmlHelp() )
  3892.             {
  3893.                 InitNavigationFramesCHM();    // Body comments frame in CHM
  3894.             }
  3895.             else if ( FMCIsWebHelp() )
  3896.             {
  3897.                 InitBodyCommentsFrameWebHelp();    // Body comments frame in WebHelp body
  3898.             }
  3899.             else if ( FMCIsDotNetHelp() )
  3900.             {
  3901.                 InitBodyCommentsFrameDotNetHelp();    // Body comments frame in DotNet Help body
  3902.             }
  3903.         }
  3904.         else if ( window.name == "glossary" && FMCIsDotNetHelp() )
  3905.         {
  3906.             InitGlossaryFrameDotNetHelp();
  3907.         }
  3908.         else if (    window.name == "toc" ||
  3909.                     window.name == "index" ||
  3910.                     window.name == "search" ||
  3911.                     window.name == "glossary" ||
  3912.                     window.name == "favorites" ||
  3913.                     window.name == "browsesequences" )    // Navigation frames in CHM
  3914.         {
  3915.             InitNavigationFramesCHM();
  3916.         }
  3917.         else if ( FMCIsTopicPopup( window ) )   // Topic popup
  3918.         {
  3919.             var currFrame    = window;
  3920.             
  3921.             while ( true )
  3922.             {
  3923.                 if ( currFrame.frames["navigation"] != null )
  3924.                 {
  3925.                     mSelf.RootFrame = currFrame;
  3926.                     
  3927.                     break;
  3928.                 }
  3929.                 
  3930.                 if ( currFrame.parent == currFrame )
  3931.                 {
  3932.                     break;
  3933.                 }
  3934.                 
  3935.                 currFrame = currFrame.parent;
  3936.             }
  3937.             
  3938.             mSelf.Initialized = true;
  3939.         }
  3940.         else if ( FMCIsDotNetHelp() )
  3941.         {
  3942.             mSelf.Initialized = true;
  3943.         }
  3944.         else
  3945.         {
  3946.             mSelf.Initialized = true;
  3947.             
  3948.             return;
  3949.         }
  3950.         
  3951.         if ( FMCIsWebHelp() )
  3952.         {
  3953.             if ( mSelf.RootFrame == null )    // Standalone topic
  3954.             {
  3955.                 return;
  3956.             }
  3957.             
  3958.             var rootFolder    = new CMCUrl( mSelf.RootFrame.document.location.href ).ToFolder();
  3959.             var href        = new CMCUrl( document.location.href );
  3960.             var subFolder    = href.ToFolder().ToRelative( rootFolder );
  3961.             
  3962.             if ( subFolder.FullPath.StartsWith( "Subsystems", false ) )
  3963.             {
  3964.                 while ( subFolder.FullPath.StartsWith( "Subsystems", false ) )
  3965.                 {
  3966.                     rootFolder = rootFolder.AddFile( "Subsystems/" );
  3967.                     subFolder = href.ToFolder().ToRelative( rootFolder );
  3968.                     
  3969.                     var projFolder = subFolder.FullPath.substring( 0, subFolder.FullPath.indexOf( "/" ) + 1 );
  3970.                     
  3971.                     rootFolder = rootFolder.AddFile( projFolder );
  3972.                     subFolder = href.ToFolder().ToRelative( rootFolder );
  3973.                 }
  3974.                 
  3975.                 var r = rootFolder.FullPath;
  3976.                 r = r.replace( /\\/g, "/" );
  3977.                 r = r.replace( /%20/g, " " );
  3978.                 r = r.replace( /;/g, "%3B" );    // For Safari
  3979.                 
  3980.                 mSelf.RootFolder = r;
  3981.             }
  3982.             else if ( subFolder.FullPath.StartsWith( "AutoMerge", false ) )
  3983.             {
  3984.                 while ( subFolder.FullPath.StartsWith( "AutoMerge", false ) )
  3985.                 {
  3986.                     rootFolder = rootFolder.AddFile( "AutoMerge/" );
  3987.                     subFolder = href.ToFolder().ToRelative( rootFolder );
  3988.                     
  3989.                     var projFolder = subFolder.FullPath.substring( 0, subFolder.FullPath.indexOf( "/" ) + 1 );
  3990.                     
  3991.                     rootFolder = rootFolder.AddFile( projFolder );
  3992.                     subFolder = href.ToFolder().ToRelative( rootFolder );
  3993.                 }
  3994.                 
  3995.                 var r = rootFolder.FullPath;
  3996.                 r = r.replace( /\\/g, "/" );
  3997.                 r = r.replace( /%20/g, " " );
  3998.                 r = r.replace( /;/g, "%3B" );    // For Safari
  3999.                 
  4000.                 mSelf.RootFolder = r;
  4001.             }
  4002.             else
  4003.             {
  4004.                 mSelf.RootFolder = FMCGetRootFolder( mSelf.RootFrame.document.location );
  4005.             }
  4006.         }
  4007.         else if ( FMCIsHtmlHelp() )
  4008.         {
  4009.             mSelf.RootFolder = "/";
  4010.         }
  4011.         else if ( FMCIsDotNetHelp() )
  4012.         {
  4013.             var pathToHelpSystem = FMCGetAttribute(document.documentElement, "MadCap:PathToHelpSystem");
  4014.             var rootFolder = new CMCUrl(document.location.href).ToFolder();
  4015.             rootFolder = rootFolder.CombinePath(pathToHelpSystem);
  4016.  
  4017.             mSelf.RootFolder = rootFolder.FullPath;
  4018.         }
  4019.     }
  4020. }
  4021.